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

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.



, , , , ,




5 responses to “Installing Apache/PHP7.0-FPM in Ubuntu 16.04 Xenial Xerus”

  1. Ted Stresen-Reuter Avatar

    Thank you. This was beginning to drive me crazy!

  2. Rob Bredow Avatar
    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?

    1. Rob Bredow Avatar
      Rob Bredow

      Naturally, 10 minutes after posting I came across a post by Tim Jones pointing me to a PPA that seems to solve the problem for me:

      I posted a summary of the steps I used to address it here as well:

      Hope that helps someone!

  3. Eric S Avatar
    Eric S

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