There is a new version of this tutorial available for Debian 9 (Stretch).

How to install PHP 7 (PHP-FPM & FastCGI) for ISPConfig 3 on Debian 8 (Jessie)

The first Beta of PHP 7 is available for download now, PHP 7 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 (Beta) as a PHP-FPM and a FastCGI version on a Debian Jessie server. These PHP 7 builds include Zend OPcache.


Preliminary Note

I will install PHP 7 that is currently in Beta at the time of this writing. 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 a fpm and FastCGI binary had been build separately. With PHP 7, both binaries can be build together, so we will have to do just one PHP build now.


Compile PHP 7 with PHP-FPM and Fastcgi

Download and extract PHP 7:

mkdir -p /opt/php-7.0.0
mkdir /usr/local/src/php5-build
cd /usr/local/src/php5-build
wget -O php-7.0.0.tar.bz2
tar jxf php-7.0.0.tar.bz2
cd php-7.0.0beta1/

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

apt-get install build-essential nano
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.0#


Configure and build PHP 7.0.0 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.0.0 --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-mysqli --with-pdo-mysql --with-mysqli --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/php5-build/php-7.0.0beta1/php.ini-production /opt/php-7.0.0/lib/php.ini
cp /opt/php-7.0.0/etc/php-fpm.conf.default /opt/php-7.0.0/etc/php-fpm.conf
cp /opt/php-7.0.0/etc/php-fpm.d/www.conf.default /opt/php-7.0.0/etc/php-fpm.d/www.conf

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

nano /opt/php-7.0.0/etc/php-fpm.conf
pid = run/

Then open /opt/php-7.0.0/etc/php-fpm.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.0.0/etc/php-fpm.d/www.conf
listen =

Debian supports Systemd as well as the traditional init scripts. 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.0.0-fpm
#! /bin/sh
# Provides:          php-7.0.0-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-7.0.0-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.0.0-fpm
insserv php-7.0.0-fpm

And now create the systemd unit file

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

with the follwoing content:

Description=The PHP 7 FastCGI Process Manager

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


And reload systemd:

systemctl daemon-reload

Finally start PHP-FPM.

For systems with traditional init system, run:

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

The result should be:

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

On servers that use systemd, use this command instead:

systemctl start php-7.0.0-fpm.service

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

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

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


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

Enable PHP 7 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.0.0) - this PHP version will be listed under this name in the website settings in ISPConfig:

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

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

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.0.0-fpm
Path to the php.ini directory: /opt/php-7.0.0/lib
Path to the PHP-FPM pool directory: /opt/php-7.0.0/etc/php-fpm.d


Share this page:

Suggested articles

18 Comment(s)

Add comment


By: rober


This Guide work also with Ubuntu 15.04?

By: till

Yes, I think it should work for the latest Ubuntu version as well.

By: Joern

It dont work for me. Installed it without error, but if I want to choose it in ISPconfig, it just jumps back to default if I want to safe the selected PHP Option :(

By: Sunil

how to update php7.0.0 beta1 beta2 with php7.0.0? Thank you

By: till

Red the same steps with 7.0 final.


the ./configure option has --with-mysqli two times.. Change the first --with-mysqli with --with-mysql like this:

./configure --prefix=/opt/php-7.0.0 --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-mysql --with-pdo-mysql --with-mysqli --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

By: Andreas

I've followed this tutorial on a basically fresh install of Debian 8 and ISPConfig 3 and seen that I lack mysql support aside mysqli. So I changed the configure command options as someone pointed out here just to get

configure: WARNING: unrecognized options: --with-mysql


Any ideas?


I'm trying to run Textpattern which still has mysql, not mysqli..

By: Madalin Ignisca

Hello Andreas.

The MySQL extension has been removed from PHP 7:

To have the old extension, you should use the latest version of PHP 5.4 for best support with it.

You could use multiple PHP versions very easy and with ISPConfig's help or even manually.

By: Marek

Its bad becose ispconfig still generate conf file with socket system, which goes to 502 Bad Gateway. Is there any solution with php 7 and socket system instead of pool listening?

By: till

ISPConfig supports both modes, socket and port and the PHP 7 configuration above works in ispconfig with socket and port mode.

By: Mtx

Hello. Thanks a lot for this tutorial, really comprehensive. 

I'm using it to setup PHP7 with nginx server. And those words make me ask this question "Please note that PHP-FPM can be used on both Apache and nginx servers, while FastCGI is available only for Apache servers.".

With PHP 5.x, i was using PHP-fpm with fastCGI to process PHP scripts (from my nginx conf files). But with those words, i dont know if I'll be able to.

So following this, i'll not be able to use fastCGI socket to pass my PHP script ? Do we need to wait for PHP7 final build ?

thanks a lot !


By: till

The current PHP 7 release will work for nginx setups as well.

By: Jürgen Dorn

Hi, thanks for your guide but I had issue to establish a database connection using PHP 7 , maybe due to usign mariadb, from what I found in the apache logs. So I configured using the correct header paths

--with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr

finally looks like:

./configure --prefix=/opt/php-7 --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-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr --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


By: Thomas

Hi, I tried to add php7 as an additional php version on my server. It runs on Ubunto 14.04.3 LTS and the latest version of ISPConfig3. All packages are up to date.

I followed the tutorial until step

insserv php-7.0.0-fpm

and used

update-rc.d php-7.0.0-fpm defaults

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


But now I run in to the following error:

-bash: /etc/init.d/php-7.0.0-fpm: /bin/sh^M: bad interpreter: No such file or directory

Does someone have an Idea, where I went wrong?

Cheers and Happy Holidays!

By: till

Checj the init file that you created, it seems as if it contains windows linebreaks ^M instead of Linux linebreaks.


Change the fpm sock for this in nginx conf -> fastcgi_pass;

And... voilá, fastCGI on nginx Ó_ò

By: gdecris

Would it be possible to add a status to the service commands? besides that this is great

By: franck

Thanks for this useful guide ! I suggest adding --with-inconv and --enable-intl build options, as these packages are often used by frameworks such as Symfony.