LinuxAn 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

[code language=”bash”]yum -y update && yum -y install wget screen && reboot[/code]

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

[code language=”bash”]timezone=$(grep -oP ‘(?<=”)\w+/\w+’ /etc/sysconfig/clock)[/code]

Add the EPEL repository for mcrypt.

[code language=”bash”]rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm[/code]

Update/Install all the packages PHP will need.

[code language=”bash”]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[/code]

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:

[code language=”bash”]yum downgrade libmcrypt[/code]

Download PHP 5.2.17

[code language=”bash”]wget http://museum.php.net/php5/php-5.2.17.tar.gz -O /usr/local/src/php-5.2.17.tar.gz[/code]

Extract PHP 5.2.17, and change to the new directory.

[code language=”bash”]tar xzvf /usr/local/src/php-5.2.17.tar.gz -C /usr/local/src/[/code]

[code language=”bash”]cd /usr/local/src/php-5.2.17/[/code]

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.

[code language=”bash”]./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[/code]

Make && Make Install

[code language=”bash”]make -j $(grep processor /proc/cpuinfo | wc -l)[/code]

[code language=”bash”][ ! -d “/usr/local/php-5.2.17/” ] && make install[/code]

Copy the php.ini to the new location.

[code language=”bash”]cp /usr/local/src/php-5.2.17/php.ini-recommended /usr/local/php-5.2.17/etc/php.ini[/code]

Include the timezone in the php.ini

[code language=”bash”]sed -i “s#;date.timezone =#date.timezone = $timezone#” /usr/local/php-5.2.17/etc/php.ini[/code]

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

[code language=”bash”]/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″[/code]

Download PHP 5.3.27

[code language=”bash”]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[/code]

Extract and change to the directory

[code language=”bash”]tar xzvf /usr/local/src/php-5.3.27.tar.gz -C /usr/local/src/[/code]

[code language=”bash”]cd /usr/local/src/php-5.3.27/[/code]

Configure PHP 5.3.27

[code language=”bash”]./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[/code]

Make and Make Install

[code language=”bash”]make -j $(grep processor /proc/cpuinfo | wc -l)[/code]

[code language=”bash”][ ! -d “/usr/local/php-5.3.27/” ] && make install[/code]

Copy php.ini to install directory

[code language=”bash”]cp -a /etc/php.ini /usr/local/php-5.3.27/etc/php.ini[/code]

Set the timezone in the php.ini file.

[code language=”bash”]sed -i “s#;date.timezone =#date.timezone = $timezone#” /usr/local/php-5.3.27/etc/php.ini[/code]

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

[code language=”bash”]/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″[/code]

 

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

Similar Posts

One Comment

  1. 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.

Leave a Reply