Apache 2.4 with php5-fpm

I’ve spent so many hours trying to make the following setup: Apache v2.4 php-fpm to work, but without any success. I am using fully updated Ubuntu Server 14.04 TLS.

Most of the tutorials online are for nginx with php-fpm or Apache 2.2, but I know things have changed.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Assuming that you’re starting with a basic LAMP stack, first you need to install the needed packages: <br> <br><pre> <br>sudo apt-get install libapache2-mod-fastcgi php5-fpm <br></pre> <br> <br>Then create the file “/etc/apache2/conf-available/php5-fpm.conf” with the contents: <br> <br><pre> <br><IfModule mod_fastcgi.c> <br> AddHandler php5-fcgi .php <br> Action php5-fcgi /php5-fcgi <br> Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi <br> FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization <br></IfModule> <br></pre> <br> <br>Then enable the new mods and config: <br> <br><pre> <br>a2enmod actions fastcgi alias <br>a2enconf php5-fpm <br>service apache2 reload <br></pre> <br> <br>You should be up and running. To verify, create a file called “/var/www/html/info.php” with the contents: <br> <br><pre> <br><?php <br>phpinfo(); <br>?> <br></pre> <br> <br>Now you should be able to browse to <br> <br>You should see a lot of information about your php set up including: "Server API FPM/FastCGI "

You may also need to switch from the apache MPM non-threaded module mpm_prefork to a threaded one.

a2dismod mpm_prefork


a2enmod mpm_worker or a2enmod mpm_event

If it’s not installed:

apt-get install apache2-mpm-worker or apt-get install apache2-mpm-event

Glad you got it working! I fixed up the tags. <br> <br> <br>For anyone else, here’s Ivan’s addition to php5-fpm.conf with the formatting fixed: <br> <br><pre> <br><Directory /usr/lib/cgi-bin> <br> Require all granted <br></Directory> <br></pre> <br> <br>