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 http://packages.dotdeb.org jessie all # php7

# add key to get php7 without errors
cd /tmp && wget https://www.dotdeb.org/dotdeb.gpg && 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/domain.com.conf
# 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://127.0.0.1:9001/home/user/http/domain.com/$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

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">