Installing PHP7-FPM with Apache2 Worker on Ubuntu
First add some prerequesites and add the PHP7 repository:
apt-get update
apt-get install software-properties-common python-software-properties
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php-7.0
Then install the actual PHP packages (remove those form the list that you do not need):
apt-get install php7.0-fpm php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-mysql php7.0-phpdbg php7.0-dbg php7.0-gd php7.0-imap php7.0-ldap php7.0-pgsql php7.0-pspell php7.0-recode php7.0-snmp php7.0-tidy php7.0-dev php7.0-intl php7.0-gd php7.0-curl
Then install Apache worker:
apt-get install apache2-mpm-worker
Now let's modify the apache configuration, so that you're using PHP7-FPM. Edit /etc/apache2/sites-enabled/000-default.conf and add the following block before </VirtualHost>:
DirectoryIndex index.php
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9000/var/www/html
</LocationMatch>
Remove index.html in /var/www/html/ which is the default document root and add a new index.php file with the following content:
<?php
echo phpinfo();
Now let's activate the proxy fcgi module and restart Apache:
a2enmod proxy_fcgi
service apache2 restart
Next in /etc/php/7.0/fpm/pool.d/www.conf comment the line containing the socket and add the line below as indicated:
; listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000
Finally restart PHP7-FPM:
service php7.0-fpm restart
And point the browser to your webserver and you're ready to go! You should see a phpinfo page.