Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing Multiple Versions of PHP for ISPConfig 3 on Centos 6.8

Installing Multiple Versions of PHP for ISPConfig 3 on Centos 6.8

Contents


Installing PHP 5.6 (PHP-FPM and Fast-CGI)

Setting up the build environment

mkdir /opt/php-5.6
mkdir /usr/local/src/php56-build
cd /usr/local/src/php56-build
wget http://www.php.net/get/php-5.6.36.tar.bz2/from/a/mirror -O php-5.6.36.tar.bz2
tar jxf php-5.6.36.tar.bz2
cd php-5.6.36

back to top

Install the build prerequisites

yum groupinstall 'Development Tools'
yum install libxml2-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel libtidy-devel libxslt-devel libmcrypt-devel pcre-devel curl-devel mysql-devel ncurses-devel gettext-devel net-snmp-devel libevent-devel libtool-ltdl-devel libc-client-devel postgresql-devel

back to top

Build and install PHP

Configure and build PHP 5.6 as follows: (use ./configure --help for available options)

./configure \
--prefix=/opt/php-5.6 \
--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 \
--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=apache \
--with-fpm-group=apache \
--with-libdir=lib64 \
--enable-ftp \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-gettext \
--enable-fpm

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM. If you want to use this PHP-FPM version with Apache, please use --with-fpm-user=apache and --with-fpm-group=apache; if you want to use this PHP-FPM version with nginx, please use --with-fpm-user=nginx and --with-fpm-group=nginx.

make && make install

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

cp /usr/local/src/php56-build/php-5.6.30/php.ini-production /opt/php-5.6/lib/php.ini
cp /opt/php-5.6/etc/php-fpm.conf.default /opt/php-5.6/etc/php-fpm.conf

Open /opt/php-5.6/etc/php-fpm.conf and adjust the following lines. The listen line, you must use an unused port (e.g. 8956; port 9000 might be in use by the default PHP-FPM already):

vim /opt/php-5.6/etc/php-fpm.conf
[...]
pid = run/php-fpm.pid
[...]
user = apache
group = apache
[...]
listen = 127.0.0.1:8956
[...]
include=/opt/php-5.6/etc/fpm.d/*.conf
[...]

Create the pool directory for PHP-FPM:

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

Next create an init script for PHP-FPM:

vim /etc/init.d/php56-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides:          php56-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php56-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-5.6/sbin/php-fpm
php_fpm_CONF=/opt/php-5.6/etc/php-fpm.conf
php_fpm_PID=/opt/php-5.6/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"

wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac
                echo -n .
                try=`expr $try + 1`
                sleep 1
        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        stop)
                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
                fi
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                       echo " done"
                fi
        ;;
        force-quit)
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        restart)
                $0 stop
                $0 start
        ;;
        reload)
                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
                fi
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
        ;;
        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;
esac

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

chmod 755 /etc/init.d/php56-fpm
chkconfig --levels 235 php56-fpm on

Finally start PHP-FPM:

service php56-fpm start

back to top

Enable the Zend OPcache extension

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

vim /opt/php-5.6/lib/php.ini

Add the following line at the end:

[...]
zend_extension=opcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable the APCu (APC User Cache) extension

The most recent version of APCu supporting PHP 5.x is APCu 4.x.

cd /opt/php-5.6/etc
pecl -C ./pear.conf update-channels
pecl -C ./pear.conf install channel://pecl.php.net/apcu-4.0.11

Accept all default values.

To enable APCu, open /opt/php-5.6/lib/php.ini.

vim /opt/php-5.6/lib/php.ini

Add the following line at the beginning of the file (before the [PHP] line):

extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.gc_ttl=600
apc.enable_cli=1
apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.mmap_file_mask=/dev/zero
;apc.shm_segments = 5

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable the Memcache extension (pecl-memcache)

Install PEAR if not installed.

yum install php-pear
cd /opt/php-5.6/etc
pecl -C ./pear.conf update-channels
pecl -C ./pear.conf install memcache

To enable Memcache, open /opt/php-5.6/lib/php.ini.

vim /opt/php-5.6/lib/php.ini

Add the following line at the end:

[...]
extension=memcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable the Memcached extension (pecl-memcached)

cd /usr/local/src/php56-build/
yum install libmemcached-devel

Download Memcached 2.2.0. This is the latest version that works with PHP 5.x.

wget https://pecl.php.net/get/memcache-2.2.0.tgz
tar zxf memcached-2.2.0.tgz
cd memcached-2.2.0

Prepare the sources by running phpize from PHP 5.6.

/opt/php-5.6/bin/phpize

Build and install the PHP memcached extension.

./configure --enable-memcached --with-php-config=/opt/php-5.6/bin/php-config
make && make install

To enable Memcached, open /opt/php-5.6/lib/php.ini.

vim /opt/php-5.6/lib/php.ini

Add the following line at the end:

[...]
extension=memcached.so

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable the ionCube Loader

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: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

** For x86: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Find the PHP extension directory.

/opt/php-5.6/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp ioncube/ioncube_loader_lin_5.6.so /opt/php-5.6/lib/php/extensions/no-debug-non-zts-20131226/ioncube.so

To enable the ionCube Loader, open /opt/php-5.6/lib/php.ini.

vim /opt/php-5.6/lib/php.ini

Add the following line at the beginning of the file (before the [PHP] line):

zend_extension = /opt/php-5.6/lib/php/extensions/no-debug-non-zts-20131226/ioncube.so
[PHP]
[...]

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable the xDebug extension

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

Prepare the build folder and download the source files.

mkdir /usr/local/src/php56-build/php-xdebug
cd /usr/local/src/php56-build/php-xdebug
wget http://xdebug.org/files/xdebug-2.5.5.tgz
tar -xvzf xdebug-2.5.5.tgz
cd xdebug-2.5.5

Prepare the sources by running phpize from PHP 5.6.

/opt/php-5.6/bin/phpize

Configure and build the xDebug extension.

./configure --with-php-config=/opt/php-5.6/bin/php-config && make

Find the PHP extension directory.

/opt/php-5.6/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/xdebug.so /opt/php-5.6/lib/php/extensions/no-debug-non-zts-20131226/

To enable Memcached, open /opt/php-5.6/lib/php.ini.

vim /opt/php-5.6/lib/php.ini

Add the following line at the end (being sure to use a full path):

[...]
zend_extension = /opt/php-5.6/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so

Restart the PHP-FPM daemon and restart Apache 2:

service php56-fpm restart
service httpd restart

back to top

Enable PHP 5.6 in ISPConfig 3

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

Additional PHP Versions - Name

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

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

Additional PHP Versions - FastCGI Settings

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

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

Additional PHP Versions - PHP-FPM Settings

back to top



Installing PHP 7.0 (PHP-FPM and Fast-CGI)

Setting up the build environment

mkdir /opt/php-7.0
mkdir /usr/local/src/php70-build
cd /usr/local/src/php70-build
wget http://www.php.net/get/php-7.0.30.tar.bz2/from/this/mirror -O php-7.0.30.tar.bz2
tar jxf php-7.0.30.tar.bz2
cd php-7.0.30

back to top

Install the build prerequisites

yum groupinstall 'Development Tools'
yum install libxml2-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel libtidy-devel libxslt-devel libmcrypt-devel pcre-devel curl-devel mysql-devel ncurses-devel gettext-devel net-snmp-devel libevent-devel libtool-ltdl-devel libc-client-devel postgresql-devel

back to top

Build and install PHP

Configure and build PHP 7.0 as follows: (use ./configure --help for available options)

./configure \
--prefix=/opt/php-7.0 \
--with-libdir=lib64 \
--disable-rpath \
--with-libxml-dir=/usr \
--with-openssl \
--with-kerberos \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--with-gettext \
--with-mhash \
--with-imap \
--with-imap-ssl \
--enable-mbstring \
--with-mcrypt \
--with-mysqli=/usr/bin/mysql_config \
--enable-opcache \
--enable-pcntl \
--with-pdo-mysql \
--with-pdo-pgsql \
--with-pgsql \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--enable-inline-optimization \
--enable-mbregex \
--with-fpm-user=apache \
--with-fpm-group=apache \
--enable-fpm \
--enable-cgi

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM. If you want to use this PHP-FPM version with Apache, please use --with-fpm-user=apache and --with-fpm-group=apache; if you want to use this PHP-FPM version with nginx, please use --with-fpm-user=nginx and --with-fpm-group=nginx.

make && make install

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

cp /usr/local/src/php70-build/php-7.0.30/php.ini-production /opt/php-7.0/lib/php.ini
cp /opt/php-7.0/etc/php-fpm.conf.default /opt/php-7.0/etc/php-fpm.conf
cp /opt/php-7.0/etc/php-fpm.d/www.conf.default /opt/php-7.0/etc/php-fpm.d/www.conf

Open /opt/php-7.0/etc/php-fpm.conf and adjust the following setting:

vim /opt/php-7.0/etc/php-fpm.conf
[...]
pid = run/php-fpm.pid
[...]

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

vim /opt/php-7.0/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8970
[...]

Next create an init script for PHP-FPM:

vim /etc/init.d/php70-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides:          php70-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php70-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-7.0/sbin/php-fpm
php_fpm_CONF=/opt/php-7.0/etc/php-fpm.conf
php_fpm_PID=/opt/php-7.0/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"

wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac
                echo -n .
                try=`expr $try + 1`
                sleep 1
        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        stop)
                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
                fi
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                       echo " done"
                fi
        ;;
        force-quit)
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        restart)
                $0 stop
                $0 start
        ;;
        reload)
                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
                fi
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
        ;;
        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;
esac

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

chmod 755 /etc/init.d/php70-fpm
chkconfig --levels 235 php70-fpm on

Finally start PHP-FPM:

service php70-fpm start

back to top

Enable the Zend OPcache extension

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

vim /opt/php-7.0/lib/php.ini

Add the following line at the end:

[...]
zend_extension=opcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable the APCu (APC User Cache) extension

PHP 7.x support was added starting with APCu version 5.x

cd /usr/local/src/php70-build/
git clone https://github.com/krakjoe/apcu
cd apcu

Prepare the sources by running phpize from PHP 7.0.

/opt/php-7.0/bin/phpize

Configure and build the APCu extension.

./configure --enable-apcu --with-php-config=/opt/php-7.0/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.0/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/apcu.so /opt/php-7.0/lib/php/extensions/no-debug-non-zts-20151012/

To enable APCu, open /opt/php-7.0/lib/php.ini.

vim /opt/php-7.0/lib/php.ini

Add the following line at the end:

[...]
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.gc_ttl=600
apc.enable_cli=1
apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.mmap_file_mask=/dev/zero
;apc.shm_segments = 5

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable the Memcache extension (pecl-memcache)

mkdir /usr/local/src/php70-build/php-memcache
cd /usr/local/src/php70-build/php-memcache
yum install libmemcache-devel

Install the Memcache PHP 7 port on GitHub. (Based on this SO answer)

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7

Prepare the sources by running phpize from PHP 7.0.

/opt/php-7.0/bin/phpize

Configure and build the PHP memcache extension.

./configure --enable-memcache --with-php-config=/opt/php-7.0/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.0/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/memcache.so /opt/php-7.0/lib/php/extensions/no-debug-non-zts-20151012/

To enable Memcache, open /opt/php-7.0/lib/php.ini.

vim /opt/php-7.0/lib/php.ini

Add the following line at the end:

[...]
extension=memcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable the Memcached extension (pecl-memcached)

yum install make gcc glibc-devel libmemcached-devel zlib-devel git
cd /usr/local/src/php70-build/

libmemcached-dev is required to build Memcached. The default repository version is not high enough and will not work.

wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm
yum install libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm libmemcached-1.0.18-2.gf.el6.x86_64.rpm libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm

Clone the Github repository

git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
git checkout -b php7 origin/php7

Prepare the sources by running phpize from PHP 7.0.

/opt/php-7.0/bin/phpize

Configure, build, and install the PHP memcache extension.

./configure --disable-memcached-sasl --with-php-config=/opt/php-7.0/bin/php-config
make && make install

To enable Memcached, open /opt/php-7.0/lib/php.ini.

vim /opt/php-7.0/lib/php.ini

Add the following line at the end:

[...]
extension=memcached.so

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable the ionCube Loader

The ionCube Loader can be installed as follows:

cd /usr/local/src/php70-build/

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

** For x86_64: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

** For x86: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Find the PHP extension directory.

/opt/php-7.0/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp ioncube/ioncube_loader_lin_7.0.so /opt/php-7.0/lib/php/extensions/no-debug-non-zts-20151012/ioncube.so

To enable the ionCube Loader, open /opt/php-7.0/lib/php.ini.

vim /opt/php-7.0/lib/php.ini

Add the following line at the beginning of the file (before the [PHP] line):

zend_extension = ioncube.so
[PHP]
[...]

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable the xDebug extension

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

Prepare the build folder and download the source files.

mkdir /usr/local/src/php70-build/php-xdebug
cd /usr/local/src/php70-build/php-xdebug
wget http://xdebug.org/files/xdebug-2.6.0.tgz
tar -xvzf xdebug-2.6.0.tgz
cd xdebug-2.6.0

Prepare the sources by running phpize from PHP 7.0.

/opt/php-7.0/bin/phpize

Configure and build the xDebug extension.

./configure --with-php-config=/opt/php-7.0/bin/php-config && make

Find the PHP extension directory.

/opt/php-7.0/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/xdebug.so /opt/php-7.0/lib/php/extensions/no-debug-non-zts-20151012

To enable xDebug, open /opt/php-7.0/lib/php.ini.

vim /opt/php-7.0/lib/php.ini

Add the following line at the end (being sure to use a full path):

[...]
zend_extension = /opt/php-7.0/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so

Restart the PHP-FPM daemon and restart Apache 2:

service php70-fpm restart
service httpd restart

back to top

Enable PHP 7.0 in ISPConfig 3

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

Additional PHP Versions - Name

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

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

Additional PHP Versions - FastCGI Settings

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

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

Additional PHP Versions - PHP-FPM Settings

back to top



Installing PHP 7.1 (PHP-FPM and Fast-CGI)

Setting up the build environment

mkdir /opt/php-7.1
mkdir /usr/local/src/php71-build
cd /usr/local/src/php71-build
wget http://www.php.net/get/php-7.1.28.tar.bz2/from/this/mirror -O php-7.1.28.tar.bz2
tar jxf php-7.1.28.tar.bz2
cd php-7.1.28

back to top

Install the build prerequisites

yum groupinstall 'Development Tools'
yum install libxml2-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel libtidy-devel libxslt-devel libmcrypt-devel pcre-devel curl-devel mysql-devel ncurses-devel gettext-devel net-snmp-devel libevent-devel libtool-ltdl-devel libc-client-devel postgresql-devel

back to top

Build and install PHP

Configure and build PHP 7.1 as follows: (use ./configure --help for available options)

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

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM. If you want to use this PHP-FPM version with Apache, please use --with-fpm-user=apache and --with-fpm-group=apache; if you want to use this PHP-FPM version with nginx, please use --with-fpm-user=nginx and --with-fpm-group=nginx.

make && make install

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

cp /usr/local/src/php71-build/php-7.1.28/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:

vim /opt/php-7.1/etc/php-fpm.conf
[...]
pid = run/php-fpm.pid
[...]

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. 8971; port 9000 might be in use by the default PHP-FPM already):

vim /opt/php-7.1/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8971
[...]

Next create an init script for PHP-FPM:

vim /etc/init.d/php71-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides:          php71-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php71-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-7.1/sbin/php-fpm
php_fpm_CONF=/opt/php-7.1/etc/php-fpm.conf
php_fpm_PID=/opt/php-7.1/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"

wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac
                echo -n .
                try=`expr $try + 1`
                sleep 1
        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        stop)
                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
                fi
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                       echo " done"
                fi
        ;;
        force-quit)
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        restart)
                $0 stop
                $0 start
        ;;
        reload)
                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
                fi
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
        ;;
        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;
esac

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

chmod 755 /etc/init.d/php71-fpm
chkconfig --levels 235 php71-fpm on

Finally start PHP-FPM:

service php71-fpm start

back to top

Enable the Zend OPcache extension

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

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

Add the following line at the end:

[...]
zend_extension=opcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable the APCu (APC User Cache) extension

PHP 7.x support was added starting with APCu version 5.x

cd /usr/local/src/php71-build/
git clone https://github.com/krakjoe/apcu
cd apcu

Prepare the sources by running phpize from PHP 7.1.

/opt/php-7.1/bin/phpize

Configure and build the APCu extension.

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

Find the PHP extension directory.

/opt/php-7.1/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/apcu.so /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303/

To enable APCu, open /opt/php-7.1/lib/php.ini.

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

Add the following line at the end:

[...]
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.gc_ttl=600
apc.enable_cli=1
apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.mmap_file_mask=/dev/zero
;apc.shm_segments = 5

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable the Memcache extension (pecl-memcache)

mkdir /usr/local/src/php71-build/php-memcache
cd /usr/local/src/php71-build/php-memcache
yum install libmemcache-devel

Install the Memcache PHP 7 port on GitHub.

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7

Prepare the sources by running phpize from PHP 7.1.

/opt/php-7.1/bin/phpize

Configure and build the PHP memcache extension.

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

Find the PHP extension directory.

/opt/php-7.1/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/memcache.so /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303/

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

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

Add the following line at the end:

[...]
extension=memcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable the Memcached extension (pecl-memcached)

yum install make gcc glibc-devel libmemcached-devel zlib-devel git
cd /usr/local/src/php71-build/

libmemcached-dev is required to build Memcached. The default repository version is not high enough and will not work.

wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm
yum install libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm libmemcached-1.0.18-2.gf.el6.x86_64.rpm libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm

Clone the Github repository

git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
git checkout -b php7 origin/php7

Prepare the sources by running phpize from PHP 7.1.

/opt/php-7.1/bin/phpize

Configure, build, and install the PHP memcached extension.

./configure --disable-memcached-sasl --with-php-config=/opt/php-7.1/bin/php-config
make && make install

To enable Memcached, open /opt/php-7.1/lib/php.ini.

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

Add the following line at the end:

[...]
extension=memcached.so

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable the ionCube Loader

The ionCube Loader can be installed as follows:

cd /usr/local/src/php71-build

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

** For x86_64: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

** For x86: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Find the PHP extension directory.

/opt/php-7.1/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp ioncube/ioncube_loader_lin_7.1.so /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303/ioncube.so

To enable the ionCube Loader, open /opt/php-7.1/lib/php.ini.

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

Add the following line at the beginning of the file (before the [PHP] line):

zend_extension = ioncube.so
[PHP]
[...]

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable the xDebug extension

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

Prepare the build folder and download the source files.

mkdir /usr/local/src/php71-build/php-xdebug
cd /usr/local/src/php71-build/php-xdebug
wget http://xdebug.org/files/xdebug-2.6.0.tgz
tar -xvzf xdebug-2.6.0.tgz
cd xdebug-2.6.0

Prepare the sources by running phpize from PHP 7.1.

/opt/php-7.1/bin/phpize

Configure and build the xDebug extension.

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

Find the PHP extension directory.

/opt/php-7.1/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/xdebug.so /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303/

To enable xDebug, open /opt/php-7.1/lib/php.ini.

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

Add the following line at the end (being sure to use a full path):

[...]
zend_extension = /opt/php-7.1/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so

Restart the PHP-FPM daemon and restart Apache 2:

service php71-fpm restart
service httpd restart

back to top

Enable PHP 7.1 in ISPConfig 3

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:

Additional PHP Versions - Name

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

Additional PHP Versions - FastCGI Settings

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

Path to the PHP-FPM init script: /etc/init.d/php71-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

Additional PHP Versions - PHP-FPM Settings

back to top



Installing PHP 7.2 (PHP-FPM and Fast-CGI)

Setting up the build environment

mkdir /opt/php-7.2
mkdir /usr/local/src/php72-build
cd /usr/local/src/php72-build
wget http://www.php.net/get/php-7.2.17.tar.bz2/from/this/mirror -O php-7.2.17.tar.bz2
tar jxf php-7.2.17.tar.bz2
cd php-7.2.17

back to top

Install the build prerequisites

yum groupinstall 'Development Tools'
yum install libxml2-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel libtidy-devel libxslt-devel libmcrypt-devel pcre-devel curl-devel mysql-devel ncurses-devel gettext-devel net-snmp-devel libevent-devel libtool-ltdl-devel libc-client-devel postgresql-devel

In order to compile PHP with zip support, libzip-devel is required. The repository version is not high enough and libzip-last-devel causes compile errors.

wget https://cmake.org/files/v3.11/cmake-3.11.1.tar.gz
tar zxvf cmake-3.11.1.tar.gz
cd cmake-3.11.1
./bootstrap
make && make install

cd ..
wget https://libzip.org/download/libzip-1.5.1.tar.gz
tar zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
/usr/local/bin/cmake ..
make && make test && make install

The libsodium-devel package is necessary for compiling PHP 7.2 with the Sodium extension, however the repository version (currently 0.4.5) is not high enough and version 1.0.8 or higher is required. Installing it from source is the easiest option.

cd /usr/local/src/php72-build
git clone -b stable https://github.com/jedisct1/libsodium.git
cd libsodium && ./configure && make check && make install

back to top

Build and install PHP

Configure and build PHP 7.2 as follows: (use ./configure --help for available options)

cd /usr/local/src/php72-build
./configure \
--prefix=/opt/php-7.2 \
--with-libdir=lib64 \
--disable-rpath \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache \
--enable-cgi \
--with-libxml-dir=/usr \
--with-openssl \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir \
--with-freetype-dir \
--with-gettext \
--with-mhash \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--enable-mbstring \
--enable-mbregex \
--with-mysqli \
--enable-opcache \
--enable-pcntl \
--with-pdo-mysql \
--enable-soap \
--enable-sockets \
--with-sodium \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-libzip \
--enable-inline-optimization

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM. If you want to use this PHP-FPM version with Apache, please use --with-fpm-user=apache and --with-fpm-group=apache; if you want to use this PHP-FPM version with nginx, please use --with-fpm-user=nginx and --with-fpm-group=nginx.

make && make install

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

cp /usr/local/src/php72-build/php-7.2.5/php.ini-production /opt/php-7.2/lib/php.ini
cp /opt/php-7.2/etc/php-fpm.conf.default /opt/php-7.2/etc/php-fpm.conf
cp /opt/php-7.2/etc/php-fpm.d/www.conf.default /opt/php-7.2/etc/php-fpm.d/www.conf

Open /opt/php-7.2/etc/php-fpm.conf and adjust the following setting:

vim /opt/php-7.2/etc/php-fpm.conf
[...]
pid = run/php-fpm.pid
[...]

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

vim /opt/php-7.2/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8972
[...]

Next create an init script for PHP-FPM:

vim /etc/init.d/php72-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides:          php72-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php72-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-7.2/sbin/php-fpm
php_fpm_CONF=/opt/php-7.2/etc/php-fpm.conf
php_fpm_PID=/opt/php-7.2/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"

wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac
                echo -n .
                try=`expr $try + 1`
                sleep 1
        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        stop)
                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
                fi
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                       echo " done"
                fi
        ;;
        force-quit)
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        restart)
                $0 stop
                $0 start
        ;;
        reload)
                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
                fi
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
        ;;
        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;
esac

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

chmod 755 /etc/init.d/php72-fpm
chkconfig --levels 235 php72-fpm on

Finally start PHP-FPM:

service php72-fpm start

back to top

Enable the Mcrypt extension (pecl-mcrypt)

Mcrypt is a PHP extension that provides bindings for the defunct libmcrypt cryptography library that hasn't been updated since 2007. It has been officially deprecated since PHP 7.1 and it's recommended replacement libsodium has been available for some time. Beginning with PHP 7.2, libsodium is included in the PHP core. All current code should be written to use Sodium, not Mcrypt. However, it can still be installed if you really need the legacy support.

cd wget https://pecl.php.net/get/mcrypt-1.0.1.tgz

back to top

Enable the Zend OPcache extension

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

vim /opt/php-7.2/lib/php.ini

Add the following line at the end:

[...]
zend_extension=opcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable the APCu (APC User Cache) extension

PHP 7.x support was added starting with APCu version 5.x

cd /usr/local/src/php72-build/
git clone https://github.com/krakjoe/apcu
cd apcu

Prepare the sources by running phpize from PHP 7.2.

/opt/php-7.2/bin/phpize

Configure and build the APCu extension.

./configure --enable-apcu --with-php-config=/opt/php-7.2/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.2/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/apcu.so /opt/php-7.2/lib/php/extensions/no-debug-non-zts-20170718

To enable APCu, open /opt/php-7.2/lib/php.ini.

vim /opt/php-7.2/lib/php.ini

Add the following line at the end:

[...]
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.gc_ttl=600
apc.enable_cli=1
apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.mmap_file_mask=/dev/zero
;apc.shm_segments = 5

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable the Memcache extension (pecl-memcache)

mkdir /usr/local/src/php72-build/php-memcache
cd /usr/local/src/php72-build/php-memcache
yum install libmemcache-devel

Install the Memcache PHP 7 port on GitHub.

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7

Prepare the sources by running phpize from PHP 7.2.

/opt/php-7.2/bin/phpize

Configure and build the PHP memcache extension.

./configure --enable-memcache --with-php-config=/opt/php-7.2/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.2/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/memcache.so /opt/php-7.2/lib/php/extensions/no-debug-non-zts-20170718

To enable Memcache, open /opt/php-7.2/lib/php.ini.

vim /opt/php-7.2/lib/php.ini

Add the following line at the end:

[...]
extension=memcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable the Memcached extension (pecl-memcached)

yum install make gcc glibc-devel libmemcached-devel zlib-devel git
cd /usr/local/src/php72-build/

libmemcached-dev is required to build Memcached. The default repository version is not high enough and will not work.

wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm
yum install libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm libmemcached-1.0.18-2.gf.el6.x86_64.rpm libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm

Clone the Github repository

git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
git checkout -b php7 origin/php7

Prepare the sources by running phpize from PHP 7.2.

/opt/php-7.2/bin/phpize

Configure, build, and install the PHP memcached extension.

./configure --disable-memcached-sasl --with-php-config=/opt/php-7.2/bin/php-config
make && make install

To enable Memcached, open /opt/php-7.2/lib/php.ini.

vim /opt/php-7.2/lib/php.ini

Add the following line at the end:

[...]
extension=memcached.so

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable the ionCube Loader

The ionCube Loader can be installed as follows:

cd /usr/local/src/php72-build

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

** For x86_64: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

** For x86: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Find the PHP extension directory.

/opt/php-7.2/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp ioncube/ioncube_loader_lin_7.2.so /opt/php-7.2/lib/php/extensions/no-debug-non-zts-20170718/ioncube.so

To enable the ionCube Loader, open /opt/php-7.2/lib/php.ini.

vim /opt/php-7.2/lib/php.ini

Add the following line at the beginning of the file (before the [PHP] line):

zend_extension = ioncube.so
[PHP]
[...]

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable the xDebug extension

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

Prepare the build folder and download the source files.

mkdir /usr/local/src/php72-build/php-xdebug
cd /usr/local/src/php72-build/php-xdebug
wget http://xdebug.org/files/xdebug-2.6.0.tgz
tar -xvzf xdebug-2.6.0.tgz
cd xdebug-2.6.0

Prepare the sources by running phpize from PHP 7.2.

/opt/php-7.2/bin/phpize

Configure and build the xDebug extension.

./configure --with-php-config=/opt/php-7.2/bin/php-config && make

Find the PHP extension directory.

/opt/php-7.2/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/xdebug.so /opt/php-7.2/lib/php/extensions/no-debug-non-zts-20170718

To enable xDebug, open /opt/php-7.2/lib/php.ini.

vim /opt/php-7.2/lib/php.ini

Add the following line at the end (being sure to use a full path):

[...]
zend_extension = xdebug.so

Restart the PHP-FPM daemon and restart Apache 2:

service php72-fpm restart
service httpd restart

back to top

Enable PHP 7.2 in ISPConfig 3

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

Additional PHP Versions - Name

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

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

Additional PHP Versions - FastCGI Settings

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

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

Additional PHP Versions - PHP-FPM Settings

back to top



Installing PHP 7.3 (PHP-FPM and Fast-CGI)

Setting up the build environment

mkdir /opt/php-7.3
mkdir /usr/local/src/php73-build
cd /usr/local/src/php73-build
wget http://www.php.net/get/php-7.3.4.tar.bz2/from/this/mirror -O php-7.3.4.tar.bz2
tar jxf php-7.3.4.tar.bz2
cd php-7.3.4

back to top

Install the build prerequisites

yum groupinstall 'Development Tools'
yum install libxml2-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel readline-devel libtidy-devel libxslt-devel libmcrypt-devel pcre-devel curl-devel mysql-devel ncurses-devel gettext-devel net-snmp-devel libevent-devel libtool-ltdl-devel libc-client-devel postgresql-devel

In order to compile PHP with zip support, libzip-devel is required. The repository version is not high enough and libzip-last-devel causes compile errors.

wget https://cmake.org/files/v3.11/cmake-3.11.1.tar.gz
tar zxvf cmake-3.11.1.tar.gz
cd cmake-3.11.1
./bootstrap
make && make install

cd ..
wget https://libzip.org/download/libzip-1.5.1.tar.gz
tar zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
/usr/local/bin/cmake ..
make && make test && make install

The libsodium-devel package is necessary for compiling PHP 7.3 with the Sodium extension, however the repository version (currently 0.4.5) is not high enough and version 1.0.8 or higher is required. Installing it from source is the easiest option.

cd /usr/local/src/php73-build
git clone -b stable https://github.com/jedisct1/libsodium.git
cd libsodium && ./configure && make check && make install

back to top

Build and install PHP

Configure and build PHP 7.3 as follows: (use ./configure --help for available options)

cd /usr/local/src/php73-build
./configure \
--prefix=/opt/php-7.3 \
--with-libdir=lib64 \
--disable-rpath \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache \
--enable-cgi \
--with-libxml-dir=/usr \
--with-openssl \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir \
--with-freetype-dir \
--with-gettext \
--with-mhash \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--enable-mbstring \
--enable-mbregex \
--with-mysqli \
--enable-opcache \
--enable-pcntl \
--with-pdo-mysql \
--enable-soap \
--enable-sockets \
--with-sodium \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-libzip \
--enable-inline-optimization

The last switch (--enable-fpm) makes sure this PHP version will work with PHP-FPM. If you want to use this PHP-FPM version with Apache, please use --with-fpm-user=apache and --with-fpm-group=apache; if you want to use this PHP-FPM version with nginx, please use --with-fpm-user=nginx and --with-fpm-group=nginx.

make && make install

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

cp /usr/local/src/php71-build/php-7.3.4/php.ini-production /opt/php-7.3/lib/php.ini
cp /opt/php-7.3/etc/php-fpm.conf.default /opt/php-7.3/etc/php-fpm.conf
cp /opt/php-7.3/etc/php-fpm.d/www.conf.default /opt/php-7.3/etc/php-fpm.d/www.conf

Open /opt/php-7.3/etc/php-fpm.conf and adjust the following setting:

vim /opt/php-7.3/etc/php-fpm.conf
[...]
pid = run/php-fpm.pid
[...]

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

vim /opt/php-7.3/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8973
[...]

Next create an init script for PHP-FPM:

vim /etc/init.d/php73-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides:          php73-fpm
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php73-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO
php_fpm_BIN=/opt/php-7.3/sbin/php-fpm
php_fpm_CONF=/opt/php-7.3/etc/php-fpm.conf
php_fpm_PID=/opt/php-7.3/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"

wait_for_pid () {
        try=0
        while test $try -lt 35 ; do
                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac
                echo -n .
                try=`expr $try + 1`
                sleep 1
        done
}
case "$1" in
        start)
                echo -n "Starting php-fpm "
                $php_fpm_BIN $php_opts
                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi
                wait_for_pid created $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        stop)
                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
                fi
                kill -QUIT `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                       echo " done"
                fi
        ;;
        force-quit)
                echo -n "Terminating php-fpm "
                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi
                kill -TERM `cat $php_fpm_PID`
                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;
        restart)
                $0 stop
                $0 start
        ;;
        reload)
                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
                fi
                kill -USR2 `cat $php_fpm_PID`
                echo " done"
        ;;
        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;
esac

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

chmod 755 /etc/init.d/php73-fpm
chkconfig --levels 235 php73-fpm on

Finally start PHP-FPM:

service php73-fpm start

back to top

Enable the Mcrypt extension (pecl-mcrypt)

Mcrypt is a PHP extension that provides bindings for the defunct libmcrypt cryptography library that hasn't been updated since 2007. It has been officially deprecated since PHP 7.1 and it's recommended replacement libsodium has been available for some time. Beginning with PHP 7.2, libsodium is included in the PHP core. All current code should be written to use Sodium, not Mcrypt. However, it can still be installed if you really need the legacy support.

cd wget https://pecl.php.net/get/mcrypt-1.0.1.tgz

back to top

Enable the Zend OPcache extension

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

vim /opt/php-7.3/lib/php.ini

Add the following line at the end:

[...]
zend_extension=opcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable the APCu (APC User Cache) extension

PHP 7.x support was added starting with APCu version 5.x

cd /usr/local/src/php73-build/
git clone https://github.com/krakjoe/apcu
cd apcu

Prepare the sources by running phpize from PHP 7.3.

/opt/php-7.3/bin/phpize

Configure and build the APCu extension.

./configure --enable-apcu --with-php-config=/opt/php-7.3/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.3/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/apcu.so /opt/php-7.3/lib/php/extensions/no-debug-non-zts-20170718

To enable APCu, open /opt/php-7.3/lib/php.ini.

vim /opt/php-7.3/lib/php.ini

Add the following line at the end:

[...]
extension=apcu.so
apc.enabled=1
apc.shm_size=128M
apc.ttl=0
apc.gc_ttl=600
apc.enable_cli=1
apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.mmap_file_mask=/dev/zero
;apc.shm_segments = 5

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable the Memcache extension (pecl-memcache)

mkdir /usr/local/src/php73-build/php-memcache
cd /usr/local/src/php73-build/php-memcache
yum install libmemcache-devel

Install the Memcache PHP 7 port on GitHub.

wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7

Prepare the sources by running phpize from PHP 7.3.

/opt/php-7.3/bin/phpize

Configure and build the PHP memcache extension.

./configure --enable-memcache --with-php-config=/opt/php-7.3/bin/php-config
make

Find the PHP extension directory.

/opt/php-7.3/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/memcache.so /opt/php-7.3/lib/php/extensions/no-debug-non-zts-20170718

To enable Memcache, open /opt/php-7.3/lib/php.ini.

vim /opt/php-7.3/lib/php.ini

Add the following line at the end:

[...]
extension=memcache.so

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable the Memcached extension (pecl-memcached)

yum install make gcc glibc-devel libmemcached-devel zlib-devel git
cd /usr/local/src/php73-build/

libmemcached-dev is required to build Memcached. The default repository version is not high enough and will not work.

wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm
wget http://mirror.symnds.com/distributions/gf/el/6/plus/x86_64/libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm
yum install libmemcached-devel-1.0.18-2.gf.el6.x86_64.rpm libmemcached-1.0.18-2.gf.el6.x86_64.rpm libmemcached-libs-1.0.18-2.gf.el6.x86_64.rpm

Clone the Github repository

git clone https://github.com/php-memcached-dev/php-memcached.git
cd php-memcached/
git checkout -b php7 origin/php7

Prepare the sources by running phpize from PHP 7.3.

/opt/php-7.3/bin/phpize

Configure, build, and install the PHP memcached extension.

./configure --disable-memcached-sasl --with-php-config=/opt/php-7.3/bin/php-config
make && make install

To enable Memcached, open /opt/php-7.3/lib/php.ini.

vim /opt/php-7.3/lib/php.ini

Add the following line at the end:

[...]
extension=memcached.so

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable the ionCube Loader

The ionCube Loader can be installed as follows:

cd /usr/local/src/php73-build

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

** For x86_64: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfvz ioncube_loaders_lin_x86-64.tar.gz

** For x86: **

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
tar xfvz ioncube_loaders_lin_x86.tar.gz

Find the PHP extension directory.

/opt/php-7.3/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp ioncube/ioncube_loader_lin_7.3.so /opt/php-7.3/lib/php/extensions/no-debug-non-zts-20170718/ioncube.so

To enable the ionCube Loader, open /opt/php-7.3/lib/php.ini.

vim /opt/php-7.3/lib/php.ini

Add the following line at the beginning of the file (before the [PHP] line):

zend_extension = ioncube.so
[PHP]
[...]

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable the xDebug extension

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

Prepare the build folder and download the source files.

mkdir /usr/local/src/php73-build/php-xdebug
cd /usr/local/src/php73-build/php-xdebug
wget http://xdebug.org/files/xdebug-2.6.0.tgz
tar -xvzf xdebug-2.6.0.tgz
cd xdebug-2.6.0

Prepare the sources by running phpize from PHP 7.3.

/opt/php-7.3/bin/phpize

Configure and build the xDebug extension.

./configure --with-php-config=/opt/php-7.3/bin/php-config && make

Find the PHP extension directory.

/opt/php-7.3/bin/php -i | grep extension_dir

Copy the extension to the PHP extension directory.

cp modules/xdebug.so /opt/php-7.3/lib/php/extensions/no-debug-non-zts-20170718

To enable xDebug, open /opt/php-7.3/lib/php.ini.

vim /opt/php-7.3/lib/php.ini

Add the following line at the end (being sure to use a full path):

[...]
zend_extension = xdebug.so

Restart the PHP-FPM daemon and restart Apache 2:

service php73-fpm restart
service httpd restart

back to top

Enable PHP 7.3 in ISPConfig 3

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

Additional PHP Versions - Name

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

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

Additional PHP Versions - FastCGI Settings

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

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

Additional PHP Versions - PHP-FPM Settings

back to top


@nmazza

This comment has been minimized.

Copy link

commented Mar 13, 2018

Helo, let me a question?
I have followed this tutorial on CentOS 6.9 and I had a problem,
After
make && make install
cp /usr/local/src/php56-build/php-5.6.30/php.ini-production /opt/php-5.6/lib/php.ini
cp /opt/php-5.6/etc/php-fpm.conf.default /opt/php-5.6/etc/php-fpm.conf

Problem: theare aren't /opt/php-5.6/lib and /opt/php-5.6/etc/php-fpm.conf.default
Coud you help me!

I don't know whats is wrong, I had checked twice.

Thanks for all
I'll appreciate your cooperation.
Nestor Mazza
nmazza@sofiha.com.ar

@thagxt

This comment has been minimized.

Copy link

commented Jul 30, 2018

Thank you very much for this! It's gold! Really helped me

@thagxt

This comment has been minimized.

Copy link

commented Mar 19, 2019

In this section: @Build and install PHP

instead of cd /usr/local/src/php72-build you need to CD once more into "php-7.2.5": `

cd /usr/local/src/php72-build\php-7.2.5
otherwise you get this error: -bash: ./configure: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.