How to install PHP 7.1 as PHP-FPM & FastCGI for ISPConfig 3.1 on Debian 8 (Jessie)

The final version of PHP 7.1 is available for download on Github and the PHP mirrors now. PHP 7.1 is the next generation of the PHP programming language, it is up to 2 times faster than PHP 5.6 and 14 times faster than PHP 5.0 according to the release notes. The new PHP version is not 100% compatible with PHP 5.x as some deprecated API's have been removed, so it is a good idea to start testing your web sites for compatibility with this new release. This can be done easily and without affecting all sites on your server by using the multi PHP version feature in ISPConfig 3. The PHP version can be selected in the ISPConfig 3 website settings for each site individually. This feature works with PHP-FPM and FastCGI. This tutorial shows how to build the new PHP 7.1 as a PHP-FPM and a FastCGI version on a Debian Jessie server. This PHP 7.1 build includes many compiled in extensions and Zend OPcache and Memcached as loadable modules.


1 Preliminary Note

I will install PHP 7.1 which has been released as final version a few days ago. Please note that PHP-FPM can be used on both Apache and Nginx servers while FastCGI is available only for Apache servers.

With older PHP versions, PHP-FPM and FastCGI had been mutually exclusive so that an FPM and FastCGI binary had to be build separately. With PHP 7.1, a single binary that supports FPM and FCGI mode can be build.


2 Compile PHP 7.1 with PHP-FPM and Fastcgi

Download and extract PHP 7.1 from Github:

mkdir -p /opt/php-7.1
mkdir /usr/local/src/php7-build
cd /usr/local/src/php7-build
wget -O php-7.1.0.tar.bz2
tar jxf php-7.1.0.tar.bz2

cd php-7.1.0/

Install the prerequisites for building PHP 7.1 and the nano editor that I will use to edit the config files:

apt-get install build-essential nano autoconf

apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

(The last command is needed if you build PHP with --with-imap, because otherwise ./configure will stop with the following error:

checking for crypt in -lcrypt... yes
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
[email protected]:/usr/local/src/php5-build/php-7.0.7#


Configure and build PHP 7.1 as follows (you can adjust the ./configure command to your needs, take a look at

./configure --help

to see all available options; if you use a different ./configure command, it is possible that additional libraries are required, or the build process will fail):

./configure --prefix=/opt/php-7.1 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM.

make install

Copy php.ini and php-fpm.conf to the correct locations:

cp /usr/local/src/php7-build/php-7.1.0/php.ini-production /opt/php-7.1/lib/php.ini

cp /opt/php-7.1/etc/php-fpm.conf.default /opt/php-7.1/etc/php-fpm.conf
cp /opt/php-7.1/etc/php-fpm.d/www.conf.default /opt/php-7.1/etc/php-fpm.d/www.conf

Open /opt/php-7.1/etc/php-fpm.conf and adjust the following setting (remove the ; in front of the pid line):

nano /opt/php-7.1/etc/php-fpm.conf

pid = run/

Then open /opt/php-7.1/etc/php-fpm.d/www.conf and adjust the listen line, you must use an unused port (e.g. 8999; port 9000 might be in use by Debian's default PHP-FPM already):

nano /opt/php-7.1/etc/php-fpm.d/www.conf

listen =

When you use multiple additional PHP versions, then ensure to use a free port, e.g. 8998, 8997 and so on for the next versions.

3 Create the init script and systemd unit file

Debian supports Systemd as well as the traditional init scripts. Most systems today use Systemd, in this case proceed with chapter 3.2, for systems with traditional init system, follow chapter 3.1 and then proceed with chapter 4. Do not install both, the systemd and init.d script, on the same system.

3.1 Create a init.d start script

First I will create an init script for the php-fpm service and then I will create a systemd unit.

First, create an init script for PHP-FPM:

nano /etc/init.d/php-7.1-fpm

#! /bin/sh
# Provides:          php-7.1-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-7.1-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
        while test $try -lt 35 ; do
                case "$1" in
                        if [ -f "$2" ] ; then
                        if [ ! -f "$2" ] ; then
                echo -n .
                try=`expr $try + 1`
                sleep 1
case "$1" in
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                        echo " done"
                echo -n "Gracefully shutting down php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                        echo " done"
                       echo " done"
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                        echo " done"
                $0 stop
                $0 start
                echo -n "Reload service php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1

Make the init script executable and create the system startup links:

chmod 755 /etc/init.d/php-7.1-fpm
insserv php-7.1-fpm

Finally start PHP-FPM:

/etc/init.d/php-7.1-fpm start

The result should be:

/etc/init.d/php-7.1-fpm start
Starting php-fpm done

3.2 Create  Systemd script for PHP 7.1

Now create the systemd unit file:

nano /lib/systemd/system/php-7.1-fpm.service

with the following content:

Description=The PHP 7.1 FastCGI Process Manager

ExecStart=/opt/php-7.1/sbin/php-fpm --nodaemonize --fpm-config /opt/php-7.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID


Enable the service and reload systemd:

systemctl enable php-7.1-fpm.service
systemctl daemon-reload

Finally start PHP-FPM:

systemctl start php-7.1-fpm.service

4 Enable Zend OPcache

To enable the Zend OPcache, open /opt/php-7.1/lib/php.ini...

nano /opt/php-7.1/lib/php.ini

... and add the following line at the end:


The Memcache and APCu extension can not be installed on PHP 7.1 yet, so I will skip their installation for now. I will update the tutorial later when the pecl extensions are compatible with PHP 7.1.

Test the PHP version:

cd /opt/php-7.1/bin
./php --version

The output should be similar to this screenshot.

PHP 7.1 with OPcache enabled

Please note: The screenshot is from PHP 7.1.0, the tutorial gets updated continuously for new PHP 7.1 versions, but we don't take new screenshots each time, so the PHP 7.1 version that you will see on your server is might be newer. The current version of this tutorial is for php-7.1.0.

5 Enable Memcache (optional)

In this chapter, I will compile and enable the PHP Memcached extension.

The first step is to install the libmemcached-dev package from Debian.

apt-get install libmemcached-dev

Then create a diretory, download the PHP memcache extension from Github, unpack the archive and enter the directory that contains the unpacked files.

mkdir /usr/local/src/php7-build/php-memcache
cd /usr/local/src/php7-build/php-memcache
cd php-memcached-php7

Prepare he sources by running the phpize command from PHP 7.1.


Configure and build the PHP memcache extension.

./configure --with-php-config=/opt/php-7.1/bin/php-config
make install

To enable the Memcache extension, open /opt/php-7.1/lib/php.ini...

nano /opt/php-7.1/lib/php.ini

... and add the following line at the end:


6 Enable PHP 7.1 in ISPConfig

In ISPConfig 3, you can configure the new PHP version under System > Additional PHP Versions. On the Name tab, you just fill in a name for the PHP version (e.g. PHP 7.1) - this PHP version will be listed under this name in the website settings in ISPConfig:

Enter the name of the custom PHP version

Go to the FastCGI Settings tab and fill out the fields as follows:

Path to the PHP FastCGI binary: /opt/php-7.1/bin/php-cgi
Path to the php.ini directory: /opt/php-7.1/lib

PHP 7.1 FastCGI

Then g to the PHP-FPM Settings tab and fill out the fields as follows:

Path to the PHP-FPM init script: /etc/init.d/php-7.1-fpm
Path to the php.ini directory: /opt/php-7.1/lib
Path to the PHP-FPM pool directory: /opt/php-7.1/etc/php-fpm.d

PHP 7.1 FPM settings

Share this page:

28 Comment(s)

Add comment


From: Alaska at: 2016-12-13 20:29:34

Hello,First off, I love ISPConfig :)I followed the tuto for the perfect debian jessie server, I don't think this is a huge problem since the step was optional but thought I would mention, tried using this tuto to add php 7 and got this error when installing memcache:


[email protected]:/usr/local/src/php7-build/php-memcache/php-memcached-php7# /opt/php-7.1/bin/phpize

Configuring for:

PHP Api Version:         20160303

Zend Module Api No:      20160303

Zend Extension Api No:   320160303

[email protected]:/usr/local/src/php7-build/php-memcache/php-memcached-php7# ./configure --with-php-config=/opt/php-7.1/bin/php-config

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for a sed that does not truncate output... /bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /opt/php-7.1

checking for PHP includes... -I/opt/php-7.1/include/php -I/opt/php-7.1/include/php/main -I/opt/php-7.1/include/php/TSRM -I/opt/php-7.1/include/php/Zend -I/opt/php-7.1/include/php/ext -I/opt/php-7.1/include/php/ext/date/lib

checking for PHP extension directory... /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303

checking for PHP installed headers prefix... /opt/php-7.1/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... re2c

checking for re2c version... 0.13.5 (ok)

checking for gawk... no

checking for nawk... nawk

checking if nawk is broken... no

checking whether to enable memcached support... yes, shared

checking for libmemcached... yes, shared

checking whether to enable memcached session handler support... yes

checking whether to enable memcached igbinary serializer support... no

checking whether to enable memcached json serializer support... no

checking whether to enable memcached msgpack serializer support... no

checking whether to enable memcached sasl support... yes

checking whether to enable memcached protocol support... no

checking whether to use system FastLZ bibrary... no

checking for ZLIB... yes, shared

checking for pkg-config... no

pkg-config not found

configure: error: Please reinstall the pkg-config distribution

[email protected]:/usr/local/src/php7-build/php-memcache/php-memcached-php7# make

make: *** No targets specified and no makefile found.  Stop.


From: till at: 2016-12-14 09:25:24

Maybe you missed installing the build-essential package?



apt-get install build-essential


if this won't help, then install the missing package manually with:


apt-get install pkg-config

From: Lenny at: 2016-12-13 20:54:59

I can't pass through step 2 (Debian 8.6, sources.list - main contrib non-free)

E: Unable to locate package libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-devE: Unable to locate package libxml2-dev libxslt1-dev

Thanks for help

From: till at: 2016-12-14 09:29:01

The packages are available here on my Debian 8.6. The sources.list is:


deb jessie main contrib non-freedeb-src jessie main contrib non-free

deb jessie/updates main contrib non-freedeb-src jessie/updates main contrib non-free

From: rene at: 2016-12-14 09:30:02

Enable Memcache (optional)

gives me the follwing error on Debian 8.6

checking for pkg-config... no

pkg-config not found

configure: error: Please reinstall the pkg-config distribution

From: till at: 2016-12-14 09:31:02

See posts above.

From: thctlo at: 2016-12-14 13:57:30

Hai, to get the build dependecy fixed, and easy fix/try is. add the sid source line to the sources.list. deb-src sid main contrib non-free

run apt-get update

run : apt-get build-dep php7.0 i dont think the depencies changed much here. Packages that didnt install due to version mismatch, install these manually. now compile php7.1


From: thctlo at: 2016-12-14 14:01:45

Till, i forgot to ask. If i setup on debian jessie and i create debian packages for php7(.1)( like the debdot versions php7.0 ) Can we still mix php5.6 with php7.x on debian jessie even with only debian packages installed? im asking this because only create debian packages and install with apt.

Source/compiling software is not allowed on my servers, so its a bit more difficult sometimes to setup.


From: Alfio Saitta at: 2016-12-16 09:33:30

Please, add the intl extension

apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev libicu-dev

 ./configure --prefix=/opt/php-7.1 --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-intl

From: M1r at: 2016-12-28 20:41:03

for php_intl error:configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.


apt-get install libicu-dev

From: Johnymas at: 2016-12-16 14:11:39


I got an error on ubuntu lts 16.04

E: Unable to locate package libjpeg62-turbo-dbg

Any suggestion?

From: till at: 2016-12-16 16:52:45

This tutorial is for Debian 8 only, not Ubuntu. The pacjage names on Ubuntu are different.

From: Johnymas at: 2016-12-16 17:44:46

Ok, thanks.

Till, is there any tutorial to install PHP 7.1 as PHP-FPM & FastCGI for ISPConfig 3.1 on ubuntu lts 16.04?

From: V-II at: 2016-12-22 20:40:04

so i've updated and installed 7.1 - appears to be going good..

biggest question...

what about updates?

another package i use is 

they utilize a script to update the /opt/php7 - /opt/php5.6 - /opt/php/7.1 folders when a new version is released


When an updated 7.1 version is released do we need to remove the service so we can continue to use the port?

would be good to upate the existing links and use a master location that is updated when a version is updated. 


Client picks 7.0 / 7.1 / 5.6 - updates happen under them...


haven't seen how ISPCP would update vs just installing a new one and manually changing sites then deleting and backing out every change - eventually using up a crazy amount of listen ports!?! if not removed manually?

From: till at: 2016-12-23 09:34:26

Compile the new version into the same folder and restart php-fpm. Or you use folders for the sub versions like /opt/php/7.1.0, /opt/php/7.1.1 etc. and create a symlink /opt/php/7.1 that points to the recent version and then alter that symlink when you compiled a new version. The ports have not to be altered when you replace a version.


Btw. the above applies to the control panel ISPConfig and not ISPCP.

From: Sunny at: 2016-12-31 23:39:30

@til to Update for further Question (i could directly comment to that):

i tested your suggestion and create /opt/php/7.1/ with symlink to /opt/php/7.1.0 where i installed all like this tutorial says, thanks for that. it seems to work fine, but i got a mail from ispconfig with "WARNING - Action aborted, file is a symlink: /opt/php/7.1/lib/php.ini" so how to work with that and what does it mean at all, because the website works and shows working php 7.1 ?! thx

From: Ralf Behrendt at: 2016-12-28 11:55:37

Please add the save command after editing the files. Maybe some beginner is not sure if he should do it or not. Because in any other case you can copy & past, but how to save nano is not mentioned.

By the way on debian 8 adn ispconfig 3 the turorial works perfect for me.

From: Thomas at: 2016-12-28 22:02:11

If you go with the systemd script option, what is the path that you set in the "Path to the PHP-FPM init script" setting in ISPConfig?

From: till at: 2016-12-29 11:30:19

Just set it as if you would have added a init script, ispconfig detects that systemd is installed and uses a systemd unit with the name of the init script. S just do it as shown in the tutorial, the settings will work for init.d and systemd.

From: Thomas at: 2016-12-30 18:31:08

Thanks a lot for your response! The thing is that the path will be non-existent. Do I have to create the init.d script in /etc/init.d/php-7.1-fpm and just rely on the fact that ISPConfig will not use it if systemd is installed or just point to the non-existent location? The reason that I'm asking is that if I leave this line empty, the new version does not show up in my users' websites.

From: till at: 2016-12-31 13:00:04

Just do what the tutorial tells you to do in step 6 on your server. If you would have to do something different, then the tutorial would have told you. It does not matter if this path exists or not.

From: onastvar at: 2016-12-31 02:54:52

ISPConfig 3.1 does not SAVE the following entries. I have to click on CANCEL to get out of the screen.

Path to the PHP-FPM init script: /etc/init.d/php-7.1-fpmPath to the php.ini directory: /opt/php-7.1/libPath to the PHP-FPM pool directory: /opt/php-7.1/etc/php-fpm.d

From: till at: 2016-12-31 13:01:24

Just tested it here, the paths save fine. I guess you might have copied a whitespace or something like that and not just the path.

From: fbarcenas at: 2017-01-06 04:45:31

Any IONCUBE for this yet??

From: Andreas at: 2017-01-06 14:07:24


i am very unexperiencend with linux an tried to follow these instructions. But after "make" and "make install" i can´t go one because the path /opt/php-7.1 is empty. What´s wrong?I use Debian 8 on bananapi

Thanks for help


From: krishna at: 2017-01-10 15:20:24

same issue

From: Maycon Brito at: 2017-01-09 00:52:51

Thank you! This was the first time that I instaled PHP from source with successfull. I put this page in my favorites.

I've installed  with debian:latest docker image and now I'm developing the Docker file from this tutorial.

From: Markus at: 2017-01-11 17:57:15

Hi, i installed the server with this tutorial

and when I try to start /etc/init.d/php-7.1-fpm i get the following error:


[email protected]:/usr/local/src/php7-build/php-7.1.0# /etc/init.d/php-7.1-fpm start

Starting php-fpm [11-Jan-2017 18:53:49] ALERT: [pool www] the process manager is missing (static, dynamic or ondemand)

[11-Jan-2017 18:53:49] ERROR: failed to post process the configuration

[11-Jan-2017 18:53:49] ERROR: FPM initialization failed


Can you help me?