Matthew Ames

Installing Apache/PHP7.0-FPM in Ubuntu 16.04 Xenial Xerus

Matthew Ames - 2016-04-04 - 1:41 pm

With recent versions of Apache, it has become a lot easier to use PHP-FPM, and with Ubuntu 16.04 being packaged with PHP 7 when it is released later this month, I thought it was worth a quick how to use all these technologies together.

Firstly, you will need to install the required applications, which this one simple command:

sudo apt install apache2 php

That’s not too different to how you would have installed it in previous versions of Ubuntu, and it will default to Php 7.

Now that they’re installed, there is a small amount of configuration needed. Run these simple commands in this order:

sudo a2dismod mpm_prefork php7.0
sudo a2enmod mpm_event proxy_fcgi
sudo a2enconf php7.0-fpm
sudo systemctl restart apache2

Now that should be everything complete.

  • Thank you. This was beginning to drive me crazy!

  • Rob Bredow

    I’m trying to use the mpm_event handler and getting the error:

    “Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.”

    This is a recently upgraded Ubuntu installation but I believe I’ve completely uninstalled php5. Everywhere I’ve seen this error, people have suggested moving over to mpm_prefork but I’d much prefer mpm_event if I can get it working. Any suggestions?

  • Eric S

    I have read and tried 25 things that did not work, this rocks! 😀 Thank you so much.