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
#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:
<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
</Directory>
</IfModule>
Then enable the configuration and restart the services to see the changes:
#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.
==================================================================