How To Use Multiple PHP Versions (PHP-FPM & FastCGI) With ISPConfig 3 (Debian Wheezy)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Follow me on Twitter

Since ISPConfig 3.0.5, it is possible to use multiple PHP versions on one server and select the optimal PHP version for a website. This feature works with PHP-FPM (starting with PHP 5.3) and FastCGI (all PHP 5.x versions). This tutorial shows how to build PHP 5.3 and PHP 5.4 as a PHP-FPM and a FastCGI version on a Debian Wheezy server. These PHP versions can be used together with the default PHP (installed through apt) in ISPConfig.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I will install PHP 5.3.22 and PHP 5.4.12, the latest PHP 5.3 and 5.4 versions at the time of this writing. I will also show how to build some additional PHP extensions such as APC, memcache, memcached, and ioncube.

Please note that PHP-FPM can be used on both Apache and nginx servers, while FastCGI is available only for Apache servers.

PHP-FPM and FastCGI are mutually exclusive in PHP 5.3 and 5.4, that's why I show two ways of building PHP, one for PHP-FPM, one for FastCGI, however you can compile PHP twice to get both, one time with --enable-fpm and one time with --enable-cgi (make sure to use different base directories, such as /opt/php-5.3.22 for PHP-FPM and /opt/phpfcgi-5.3.22 for FastCGI).


2 Building PHP 5.3.22 (PHP-FPM)

Download and extract PHP 5.3.22:

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

cd php-5.3.22/

Install the prerequisites for building PHP5:

apt-get install build-essential

apt-get build-dep php5

apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-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.


Configure and build PHP 5.3.22 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.3.22 \
--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 \

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.3.22/php.ini-production /opt/php-5.3.22/lib/php.ini

cp /opt/php-5.3.22/etc/php-fpm.conf.default /opt/php-5.3.22/etc/php-fpm.conf

Open /opt/php-5.3.22/etc/php-fpm.conf and adjust the following settings - in 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), and you must add the line include=/opt/php-5.3.22/etc/pool.d/*.conf at the end:

vi /opt/php-5.3.22/etc/php-fpm.conf

pid = run/
user = www-data
group = www-data
listen =

Create the pool directory for PHP-FPM:

mkdir /opt/php-5.3.22/etc/pool.d

Next create an init script for PHP-FPM:

vi /etc/init.d/php-5.3.22-fpm

#! /bin/sh
# Provides:          php-5.3.22-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-5.3.22-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-5.3.22-fpm
insserv php-5.3.22-fpm

Finally start PHP-FPM:

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

As long as there are no pools in /opt/php-5.3.22/etc/pool.d, you will get this warning which you can ignore:

root@server1:/usr/local/src/php5-build/php-5.3.22# /etc/init.d/php-5.3.22-fpm start
Starting php-fpm [04-Mar-2013 14:58:41] WARNING: Nothing matches the include pattern '/opt/php-5.3.22/etc/pool.d/*.conf' from /opt/php-5.3.22/etc/php-fpm.conf at line 512.

That's it - if you like, you can now install some additional modules like APC, memcache, memcached, and ioncube.

The APC, memcache, and memcached modules can be installed through PEAR which we must install and initialize first:

apt-get -y install php-pear

cd /opt/php-5.3.22/etc

pecl -C ./pear.conf update-channels

APC can now be installed as follows:

pecl -C ./pear.conf install apc

Accept all default values. Afterwards, open /opt/php-5.3.22/lib/php.ini...

vi /opt/php-5.3.22/lib/php.ini

... and add the line at the end of the file (you can also configure some additional APC settings):

;apc.shm_segments = 5

The memcache extension can be installed as follows:

pecl -C ./pear.conf install memcache

Open /opt/php-5.3.22/lib/php.ini...

vi /opt/php-5.3.22/lib/php.ini

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


The memcached extension can be installed as follows:

apt-get install libmemcached-dev

pecl -C ./pear.conf install memcached

Open /opt/php-5.3.22/lib/php.ini...

vi /opt/php-5.3.22/lib/php.ini

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


The ionCube Loader can be installed as follows:

cd /tmp

Next download and unpack the correct ionCube Loader package for your architecture (x86_64 or x86).

For x86_64:

tar xfvz ioncube_loaders_lin_x86-64.tar.gz

For x86:

tar xfvz ioncube_loaders_lin_x86.tar.gz

Proceed as follows:

cp ioncube/ /opt/php-5.3.22/lib/php/extensions/no-debug-non-zts-20090626/
vi /opt/php-5.3.22/lib/php.ini

Add the line zend_extension = /opt/php-5.3.22/lib/php/extensions/no-debug-non-zts-20090626/ right at the beginning of the file (before the [PHP] line):

zend_extension = /opt/php-5.3.22/lib/php/extensions/no-debug-non-zts-20090626/

Reload PHP-FPM afterwards:

/etc/init.d/php-5.3.22-fpm reload

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

Go to the PHP-FPM Settings tab (the FastCGI Settings tab can be left empty) and fill out the fields as follows:

Share this page:

24 Comment(s)

Add comment


From: Normen Marienfeld

Hallo zusammen,

Habe alles so gemacht wie im Tutorial beschrieben bleibe aber leider hängen bei:

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

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

 x86_64-linux-gnu existiert bei mir gar nicht ?

was kann ich da machen ?



Debian 6.0 (Squeeze)



Wheezy uses different /lib /lib64 structure than Squeeze does.

 You might need to use --with-libdir=lib64 instead.

 See for Squeeze compatible ./configure.

From: Anonymous


 i have two WHEEZY machines one is with SID and other with stable repositories and both systems have /usr/lib/x86_64-linux-gnu/ folder.

I don't know why your WHEEZY does not contain this folder:

Ask by debian or find this directory and set it in --with-libdir= option.


From: likufanele

For Wheezy x32 bit you have to change the configure line from

--with-libdir=/lib/x86_64-linux-gnu \


--with-libdir=/lib \

From: Peterb

these instructions have an error.

This line does not work

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

After searching the directories, x86_64-linux-gnu does not exist.

The error is ln: filed to create symbolic link

libc-client.a   no such file


From: Evil Kitten

Hello, was doing the same with new 5.3.26 and got the error
 configure: error: xml2-config not found. Please check your libxml2 installation.
 had to install  libxml2-dev to fix it.

From: Brian

when I run the step When I use "Make" then Make Install, (Installing PHP-5.3.3). in the console show me this error

 ext/openssl/xp_ssl.o: In function `php_openssl_setup_crypto':                                                              

/usr/local/src/php5-build/php-5.3.3/ext/openssl/xp_ssl.c:353: undefined reference to `SSLv2_server_method'                 

/usr/local/src/php5-build/php-5.3.3/ext/openssl/xp_ssl.c:333: undefined reference to `SSLv2_client_method'                 

collect2: error: ld returned 1 exit status                                                                                 

make: *** [sapi/fpm/php-fpm] Error 1                                                                                       

root@server php5-build/php-5.3.3#



 How i Can solve this?

From: Julien Meyer


I had the same problem. It's a bug

Apply the patch debian_patches_disable_SSLv2_for_openssl_1_0_0.patch and it will work. 


From: Anonymous

For me show this error.
checking whether libmemcached supports sasl... no
configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check
ERROR: `/tmp/pear/temp/memcached/configure --with-libmemcached-dir=no' failed

From: Daniele

i have same problem....

and i unable to install 


checking whether libmemcached supports sasl... no
configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check
ERROR: `/tmp/pear/temp/memcached/configure --with-libmemcached-dir=no' failed

there is not a workaround?????


In installed memcached like this:

cd /tmp

pecl download memcached-${pecl_memcached_ver}
tar xzvf memcached-${pecl_memcached_ver}.tgz
cd memcached-${pecl_memcached_ver}/
./configure --disable-memcached-sasl --with-php-config=/opt/php-5.3.29/bin/php-config

make install

cd ..
rm -r memcached-${pecl_memcached_ver}

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


/etc/init.d/php-5.3.29-fpm reload


From: Bruno

Thank !


There was an error in dns.c

error: undefined reference to '__dn_expand'


Add " -lresolv" to EXTRA_LIBS in Makefile.


From: Anonymous

Compiling php 5.3.28 on debian jessie (testing) does not work without some changes.
First, freetype.h was not found. In line 32280 I removed

 if test -f "$i/include/freetype2/freetype/freetype.h"; then

 and added

 if test -f "$i/include/freetype2/freetype.h"; then

After that freetype.h was found.


checking whether build with IMAP works... no
configure: error: build test failed. Please check the config.log for details.

To solve that error I had to add /usr as path for --with-openssl and --with-imap:
--with-openssl=/usr --with-imap=/usr

From: mustafa

For  FastCGI is this line necessary?

--with-fpm-user=www-data \ --with-fpm-group=www-data \

From: mattheoh


I just installed ISP Config 3 on Jessie (debian 8), so I have last PHP version.

I would like to add PHP 5.4.40 version.

I follow this tutorial but I have a problem at this step : cp /opt/php-5.4.40/etc/php-fpm.conf.default /opt/php-5.4.40/etc/php-fpm.conf

I have this return :

cp: cannot stat '/opt/php-5.4.40/etc/php-fpm.conf.default': No such file or directory


Can t find anywhere this php-fpm.conf.default

Would you have an idea ?

Thanks !

From: dx007

Hello !

I got an error when i'm running the following command on chapter 4:

apt-get build-dep php5



Note, selecting 'libc-client2007e-dev' instead of 'libc-client-dev'The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.5 but it is not going to be installedE: Build-dependencies for php5 could not be satisfied.

I can't go further, please can you help ?

Thank you very much !


From: Luigi

I followed the "how to" but at the start of php tells me this error

Starting php-fpm Jul 21 21:30:10.081954 [WARNING] Nothing matches the include pattern '/opt/php-5.3.3/etc/pool.d/*.conf' from /opt/php-5.3.3/etc/php-fpm.conf at line 274.Jul 21 21:30:10.082009 [WARNING] [pool www] pm.start_servers is not set. It's been set to 20.................................... failed

Any idea?


From: fdsfds

is this reliable ? you have 2 times the same page about installing 5.3, then you also install 5.4 instead of just compiling it... it does not make any sense

From: till

Off course it's reliable and makes sense ;) Read the tutorial closely, you compile php 5.3 as fcgi + php 5.3 as fpm + php 5.3 as fcgi + php 5.4 as fpm, this makes 4 compile sessions altogether as a php binary can only support fpm or fcgi but not both modes at the same time. If you don't want to use PHP in fpm and fcgi mode, then you can leave out either the fpm or fcgi version.

From: gfdg

and a 4th page doing exactly the same

dude are you on something ?

From: till

It's not the same. We have a nice tutorial on diff tools if you can't see the differences on your own at and I'll recommend to check out the PHP documentation at if you dont know the differences of a fcgi and a fpm PHP binary.

From: Aivaras

This manual do not work on debian 8.


Connecting to (||:80... connected.HTTP request sent, awaiting response... 404 Not Found


Impossible to download any version..

From: till

Your problem is not related to the sue of Debian 8. php.nt has moved the old php versions to the php archive, you can download them from there.