Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Migrating from Apache/mod_php to Apache/php-fpm  (Read 3896 times)

0 Members and 1 Guest are viewing this topic.


  • Guest
Migrating from Apache/mod_php to Apache/php-fpm
« on: July 09, 2018, 02:05:08 pm »
Here is what I did and what you should do to migrate to php-fpm if you are running Ubuntu 16.04 and using PHP 7.0

Code: [Select]
#sudo apt-get remove libapache2-mod-php7.0 # remove mod_php
# sudo apt-get -y install php7.0-fpm libapache2-mod-fastcgi # install php-fpm
# sudo a2dismod mpm_worker mpm_prefork # disable the conflicting modules
# sudo a2enmod actions fastcgi alias rewrite mpm_event - enable the required modules

Add the following configuration to /etc/apache2/conf-available/php7.0-fpm.conf:

Code: [Select]
<IfModule mod_fastcgi.c>
    SetHandler php7-fcgi .php
    Action php7-fcgi /php7-fcgi virtual
    Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
    FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization -idle-timeout 3600
    <Directory /usr/lib/cgi-bin>
        Require all granted

Then enable the configuration and restart the services to see the changes:

Code: [Select]
#sudo a2enconf php7.0-fpm -  enable the php-fpm configuration
#service apache2 restart
#service php7.0-fpm restart

That’s all. You should have your web server up and running with php-fpm now.