php7.0-fpm on apache2.4 and Debian 8 ‘Jessie’

It seems to be impossible to find a proper guide for php7.0-fpm so I’m going to post one here. This is Debian 8 ‘Jessie’ specific. It assumes you’re using apache2.4 and that you are serving files from somewhere in your /home/user directories rather than something retarded like /var/www/html. This uses TCP sockets rather than Unix domain sockets.

Feel free to point out anything you think is a security/config issue.

# in /etc/apt/sources.list
deb jessie all # php7

# add key to get php7 without errors
cd /tmp && wget && apt-key add dotdeb.gpg && rm dotdeb.gpg && cd

# install php7.0-fpm and things you’ll likely need. you already have apache install, right?
apt-get install php7.0-fpm php7.0-mysql php7.0-apcu php7.0-mcrypt php7.0-mbstring

# enable shit
a2enmod proxy proxy_fcgi
a2enconf php7.0-fpm
phpenmod mcrypt
phpenmod mbstring

# copy and modify php-fpm pool files for each user
cp /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.0/fpm/pool.d/
# update line 4 with username
# update line 23 with username
# update line 24 with group (users)
# update line 38 with correct port
# different username and port for every site that you want on a unique pool

# within apache virtualhost’s
RewriteEngine On
RewriteBase /
RewriteOptions InheritBefore
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([^\.]+\.php)$ fcgi://$1 [L,P]
# change the last line with the correct port, username/path obviously

# add inside your virtualhost to enable custom error pages. don’t forget your error ErrorDocument lines
ProxyErrorOverride On

Microsoft Windows and “No to All”

While copying files in Microsoft Windows you might be asked whether you want to replace an existing file or folder. You will be given four options “Yes”, “Yes to All”, “No” and “Cancel”. Performing a “No to All” function is extremely simple. Hold down the Shift key and click “No”.

Windows 10 has a different dialog so this doesn’t apply on that disaster.