How To Build PHP 5.5 (PHP-FPM & FastCGI) With ionCube Loader, Zend OPcache And APCu For 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.5 as a PHP-FPM and a FastCGI version on a Debian Wheezy server. These PHP 5.5 builds include the ionCube Loader, Zend OPcache, and APCu.

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


1 Preliminary Note

I will install PHP 5.5.7, the latest PHP 5.5 version at the time of this writing. I will also show how to build some additional PHP extensions such as APCu, 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.5, 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.5.7 for PHP-FPM and /opt/phpfcgi-5.5.7 for FastCGI).


2 Building PHP 5.5.7 (PHP-FPM)

Download and extract PHP 5.5.7:

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

cd php-5.5.7/

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.
[email protected]:/usr/local/src/php5-build/php-5.5.7#


Configure and build PHP 5.5.7 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.5.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-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 \

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.5.7/php.ini-production /opt/php-5.5.7/lib/php.ini
cp /opt/php-5.5.7/etc/php-fpm.conf.default /opt/php-5.5.7/etc/php-fpm.conf

Open /opt/php-5.5.7/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.5.7/etc/pool.d/*.conf at the end:

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

Create the pool directory for PHP-FPM:

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

Next create an init script for PHP-FPM:

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

Finally start PHP-FPM:

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

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

[email protected]:/usr/local/src/php5-build/php-5.5.7# /etc/init.d/php-5.5.7-fpm start
Starting php-fpm [07-Jan-2014 18:04:16] WARNING: Nothing matches the include pattern '/opt/php-5.5.7/etc/pool.d/*.conf' from /opt/php-5.5.7/etc/php-fpm.conf at line 520.
[email protected]:/usr/local/src/php5-build/php-5.5.7#

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

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

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


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

The APCu, 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.5.7/etc
pecl -C ./pear.conf update-channels

APCu can now be installed as follows:

pecl -C ./pear.conf install channel://

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

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

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

;apc.shm_segments = 5

The memcache extension can be installed as follows:

pecl -C ./pear.conf install memcache

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

vi /opt/php-5.5.7/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.5.7/lib/php.ini...

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

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


Since January 3, the ionCube loader is available for PHP 5.5. 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.5.7/lib/php/extensions/no-debug-non-zts-20121212/
vi /opt/php-5.5.7/lib/php.ini

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

zend_extension = /opt/php-5.5.7/lib/php/extensions/no-debug-non-zts-20121212/

Reload PHP-FPM afterwards:

/etc/init.d/php-5.5.7-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.5.7) - 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:

Suggested articles

7 Comment(s)

Add comment


By: appserver

This is amazing how to articles and really great to see how you present this to save us lots of time searching on google. :)

By: Harry

If I only want to use the php-fpm process that uses php 5.5.7 how do I disable the default debian php-fpm process that uses and older version of php? Will I save some memory doing this?

By: radim_h

Have you someone tried to install imagick php library?

When i tried pecl -C ./pear.conf install channel://

i get errorchecking ImageMagick MagickWand API configuration program... configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.ERROR: `/tmp/pear/temp/imagick/configure --with-imagick' failed


By: Patrick


First, thanks for your greats HowTo, all are incredible

When install memcached "pecl -C ./pear.conf install memcached" I have the next error


configure: error no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check


Any solution?

Thanks in advance

By: tom.1

I ran into the same error

I then installed memcached manually (paths apply for PHP 5.5.26)

It's important to use phpize and php-config of the target-version of php


cd /usr/local/src/php5-build

pecl -C /opt/php-5.5.26/etc/pear.conf download memcached

tar xzf memcached-2.2.0.tgz

cd memcached-2.2.0


./configure  --with-php-config=/opt/php-5.5.26/bin/php-config --disable-memcached-sasl --prefix=/opt/php-5.5.26


make install

By: dongbak cha

Hi, all

I thank you for the kind guidance.

In My Centos7,  when i use  apt-get . . . ,

bash: apt-get: command not found...

What should I do?


By: suther

 Thank you, very much. 

Worked like a charm in 20 Minutes on my Debian Wheeze and ISPconfig

Now I'll search for an HowTo for php7 :)