How to install PHP 5.6 as additional PHP-FPM & FastCGI for ISPConfig 3.1 on Ubuntu 16.04

This tutorial shows how to build PHP 5.6 as a PHP-FPM and a FastCGI version on Ubuntu 16.04 (Xenial Xerus). Ubuntu 16.04 ships with PHP 7 by default but there are still many websites out there that don't support PHP 7. This tutorial will show you how to install PHP 5.6 as additional PHP version on Ubuntu 16.04 so that you can switch between both versions for each website individually in ISPConfig.


1 Preliminary Note

I will install PHP 5.6 in /opt so that the main PHP 7 of Ubuntu is not affected and PHP 7 will stay the default PHP of our server while PHP 5.6 is available as option in ISPConfig (website settings). Please note that PHP-FPM can be used on both Apache and Nginx servers while FastCGI is available only for Apache servers in ISPConfig.

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 5.6, a single binary that supports FPM and FCGI mode can be build.


2 Compile PHP 5.6 with PHP-FPM and Fastcgi

Install the prerequisites to build PHP 5.6, wget and the nano editor that I will use to edit the config files:

apt-get install build-essential wget nano
apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-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.


Download and extract PHP 5.6 from

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

Configure and build PHP 5.6.30 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-5.6.30 --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-gettext --with-xmlrpc --with-xsl --with-kerberos --enable-fpm

The above string is just one long command, do not add any line breaks. 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-5.6.30/php.ini-production /opt/php-5.6.30/lib/php.ini
cp /opt/php-5.6.30/etc/php-fpm.conf.default /opt/php-5.6.30/etc/php-fpm.conf

Create the pool file directory php-fpm.d.

mkdir /opt/php-5.6.30/etc/php-fpm.d

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

nano /opt/php-5.6.30/etc/php-fpm.conf
pid = run/
user = www-data
group = www-data
listen =

2.1 Install xDebug extension (optional)

The xDebug module is a debugging extension for PHP. The installation is optional.

Install xDebug with these commands.

cd /opt/php-5.6.30/etc
pecl -C ./pear.conf update-channels
pecl -C ./pear.conf install xdebug

Then edit the php.ini file with an editor:

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

and add the following line at the end of the file:


3 Create the systemd unit file

Ubuntu 16.04 uses systemd as init system. I will create a systemd unit file to be able to start / stop and restart the PHP-FPM service.

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

with the following content:

Description=The PHP 5.6 FastCGI Process Manager

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


Enable the service and reload systemd:

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

Finally start PHP-FPM.

systemctl start php-5.6.30-fpm.service

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

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

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


Test the PHP version:

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

The output should be similar to this screenshot.

4 Enable PHP 5.6 in ISPConfig

In ISPConfig 3.1, 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 5.6.30) - this PHP version will be listed under this name in the website settings in ISPConfig:

Add PHP 5.6 in ISPConfig

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

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

PHP-FCGI settings

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

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

PHP-FPM settings

Share this page:

51 Comment(s)