Request a consult
Placeholder

Install Multiple PHP Versions on Plesk 11.5 CentOS 6.4 x64

September 16th, 2013 by Didier Bizimungu


An automated Plesk  update upgraded PHP to 5.4.x breaking older sites hosted on the server. Our Admins noticed that Plesk Linux 11.5 finally supported multiple versions of PHP, much like the Plesk Windows version. After upgrading to Plesk 11.5 we discovered that the installation instructions to install multiple versions of PHP were slightly incomplete.

After banging our heads against the wall we finally found someone who posted: Compiling multiple PHP versions for Plesk 11.5 ( CentOS 6.4 x64 ) that was able to resolve the problem, but unfortunately there we still a few things missing.

Here are the steps we took to get PHP 5.2.17 & PHP 5.3.27 installed on CentOS 6.4 x64.

Update the system and packages

yum -y update && yum -y install wget screen && reboot

Store the timezone, we’ll need to add this to the php.ini later.

timezone=$(grep -oP '(?<=")\w+/\w+' /etc/sysconfig/clock)

Add the EPEL repository for mcrypt.

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Update/Install all the packages PHP will need.

yum -y install gcc make gcc-c++ cpp kernel-headers.x86_64 libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel openldap-devel postgresql-devel aspell-devel net-snmp-devel libxslt-devel libc-client-devel libicu-devel gmp-devel curl-devel libmcrypt-devel unixODBC-devel pcre-devel sqlite-devel db4-devel enchant-devel libXpm-devel mysql-devel readline-devel libedit-devel recode-devel libtidy-devel

The one thing that was unique to our environments was mcrypt had to be downgraded in order for libmcrypt-devel to be installed.
Run this if you get a libmcrypt version errors:

yum downgrade libmcrypt

Download PHP 5.2.17

wget http://museum.php.net/php5/php-5.2.17.tar.gz -O /usr/local/src/php-5.2.17.tar.gz

Extract PHP 5.2.17, and change to the new directory.

tar xzvf /usr/local/src/php-5.2.17.tar.gz -C /usr/local/src/
cd /usr/local/src/php-5.2.17/

Configure PHP
If you receive any configure errors you’ll need to diagnose specifically for your system, but most common error is because you’re missing required packages.

./configure --with-libdir=lib64 --cache-file=./config.cache --prefix=/usr/local/php-5.2.17 --with-config-file-path=/usr/local/php-5.2.17/etc --disable-debug --with-pic --disable-rpath --with-bz2 --with-curl --with-freetype-dir=/usr/local/php-5.2.17 --with-png-dir=/usr/local/php-5.2.17 --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr/local/php-5.2.17 --with-openssl --with-pspell --with-pcre-regex --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-wddx --with-kerberos --with-unixODBC=/usr --enable-shmop --enable-calendar --with-libxml-dir=/usr/local/php-5.2.17 --enable-pcntl --with-imap --with-imap-ssl --enable-mbstring --enable-mbregex --with-gd --enable-bcmath --with-xmlrpc --with-ldap --with-ldap-sasl --with-mysql=/usr --with-mysqli --with-snmp --enable-soap --with-xsl --enable-xmlreader --enable-xmlwriter --enable-pdo --with-pdo-mysql --with-pdo-pgsql --with-pear=/usr/local/php-5.2.17/pear --with-mcrypt --without-pdo-sqlite --with-config-file-scan-dir=/usr/local/php-5.2.17/php.d --enable-fastcgi

Make && Make Install

make -j $(grep processor /proc/cpuinfo | wc -l)
[ ! -d "/usr/local/php-5.2.17/" ] && make install

Copy the php.ini to the new location.

cp /usr/local/src/php-5.2.17/php.ini-recommended /usr/local/php-5.2.17/etc/php.ini

Include the timezone in the php.ini

sed -i "s#;date.timezone =#date.timezone = $timezone#" /usr/local/php-5.2.17/etc/php.ini

Finally use the following command to add the new PHP install to the Plesk Panel, PHP version selection.

/usr/local/psa/bin/php_handler --add -displayname "5.2.17" -path /usr/local/php-5.2.17/bin/php-cgi -phpini /usr/local/php-5.2.17/etc/php.ini -type fastcgi -id "fastcgi-5.2.17"

Download PHP 5.3.27

wget http://be2.php.net/get/php-5.3.27.tar.gz/from/this/mirror -O /usr/local/src/php-5.3.27.tar.gz

Extract and change to the directory

tar xzvf /usr/local/src/php-5.3.27.tar.gz -C /usr/local/src/
cd /usr/local/src/php-5.3.27/

Configure PHP 5.3.27

./configure --with-libdir=lib64 --cache-file=./config.cache --prefix=/usr/local/php-5.3.27 --with-config-file-path=/usr/local/php-5.3.27/etc --disable-debug --with-pic --disable-rpath --with-bz2 --with-curl --with-freetype-dir=/usr/local/php-5.3.27 --with-png-dir=/usr/local/php-5.3.27 --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr/local/php-5.3.27 --with-openssl --with-pspell --with-pcre-regex --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-wddx --with-kerberos --with-unixODBC=/usr --enable-shmop --enable-calendar --with-libxml-dir=/usr/local/php-5.3.27 --enable-pcntl --with-imap --with-imap-ssl --enable-mbstring --enable-mbregex --with-gd --enable-bcmath --with-xmlrpc --with-ldap --with-ldap-sasl --with-mysql=/usr --with-mysqli --with-snmp --enable-soap --with-xsl --enable-xmlreader --enable-xmlwriter --enable-pdo --with-pdo-mysql --with-pdo-pgsql --with-pear=/usr/local/php-5.3.27/pear --with-mcrypt --without-pdo-sqlite --with-config-file-scan-dir=/usr/local/php-5.3.27/php.d --without-sqlite3 --enable-intl

Make and Make Install

make -j $(grep processor /proc/cpuinfo | wc -l)
[ ! -d "/usr/local/php-5.3.27/" ] && make install

Copy php.ini to install directory

cp -a /etc/php.ini /usr/local/php-5.3.27/etc/php.ini

Set the timezone in the php.ini file.

sed -i "s#;date.timezone =#date.timezone = $timezone#" /usr/local/php-5.3.27/etc/php.ini

Finally use the following command to add the new PHP install to the Plesk Panel, PHP version selection.

/usr/local/psa/bin/php_handler --add -displayname "5.3.27" -path /usr/local/php-5.3.27/bin/php-cgi -phpini /usr/local/php-5.3.27/etc/php.ini -type fastcgi -id "fastcgi-5.3.27"

 

Hopefully that helps some of you out there who are having trouble getting PHP installed on Plesk 11.5

2 Responses to “Install Multiple PHP Versions on Plesk 11.5 CentOS 6.4 x64”

  1. Alessandro Says:

    A really awesome tutorial. Thanks a lot!

    The tip about downgrading libmcrypt was essential for me, too.

    I spent a day and a night trying to downgrade PHP from 5.4 to 5.3, then I resolved to upgrade Plesk and install 5.3 separately. Your guide made it very easy.

    I wonder (and I suppose you do the same) why Parallels is making Plesk worse with each version. Number 9 contained the last improvements, then 10, 11 and 11.5 are a big regression in terms of interface and complexity. We have already bought a first Webmin server for a customer, and will try Cpanel with the next. I think that by the time Plesk 12 is ready, with the next batch of… regressions, we might be ready to leave it.

  2. Hörchner Says:

    Really thanks for this post. It helped me since a Plesk 11.5 #28 component update removed PHP 5.3 / upgraded to PHP 5.4.x. This update to PHP 5.4 broke some websites.
    After following these instructions PHP 5.3 is available again.