Install Second Version of PHP on Plesk

1. Download php from http://www.php.net/releases/

2. Unpack the tarball to your home directory

tar -xjf php-5.2.10.tar.bz2

3. Get module list

php -m | grep -v -e Modules] -e ^$ > php-default-modules

4. Create a configure script

for i in $(cat php-default-modules); do echo -n “–with-$i “>> phpconfigure.sh ;done

5. Edit phpconfigure.sh and insert these 2 lines to the beginning of the file

#!/bin/bash
./configure

6. Run the configure script

./phpconfigure.sh

7. Correct the errors with the help of this command:

./configure –help

To correct the errors, you may need to replace ‘–with’ with ‘–enable’, and remove those modules that are enabled by default.

8. Add other options that you need, such as –enable-safe-mode

9. Create and run phpinfo.php

echo phpinfo();

10. Grab the configure entries from phpinfo.php. Remember not to include ‘–with-apxs2=/usr/sbin/apxs’, and Make sure to change ‘–with-config-file-path=/etc’ and ‘–with-config-file-scan-dir=/etc/php.d’.

A sample phpconfigure.sh

#!/bin/bash
./configure –prefix=/usr/share –datadir=/usr/share –libdir=/usr/lib64 –libexecdir=/usr/libexec –localstatedir=/var –sharedstatedir=/usr/com –mandir=/usr/share/man –infodir=/usr/share/info –cache-file=../config.cache –with-libdir=lib64 –includedir=/usr/include –bindir=/usr/bin –sbindir=/usr/sbin –sysconfdir=/etc –with-config-file-path=/etc/php52 –with-config-file-scan-dir=/etc/php.5.2.d –with-jpeg-dir=/usr –enable-force-cgi-redirect –enable-discard-path –with-bz2 –enable-calendar –enable-exif –enable-ftp –with-gd –with-gettext –with-gmp –with-iconv –enable-mbstring –with-mcrypt –with-mysql=/usr/bin/ –with-mysqli –with-openssl –with-pdo_mysql –with-PDO_ODBC –with-pdo_sqlite –enable-shmop –enable-sockets –with-xmlrpc –with-xsl –enable-zip –with-zlib

11. Run ./phpconfigure.sh again until all errors are fixed.

12. Run ‘make’.

13. Fix the errors.

14. Run ‘make’ again until all errors are fixed.

15. Duplicate php.ini

mkdir /etc/php52/
cp php.ini-dist /etc/php52/php.ini

16. Duplicate the additional .ini files

mkdir /etc/php.5.2.d
cp /etc/php.d/*.* /etc/php.5.2.d/

17. Change permission of the cgi-bin folder

chmod 755 /var/www/vhosts/domain.com/cgi-bin

18. Copy the php-cgi to the cgi-bin folder

cp sapi/cgi/php-cgi /var/www/vhosts/domain.com/cgi-bin/
chown domain.psacln /var/www/vhosts/domain.com/cgi-bin/php-cgi
chmod 755 /var/www/vhosts/domain.com/cgi-binphp-cgi

19 . Create the apache config file

vim /var/www/vhosts/domain.com/conf/vhost.conf
ScriptAlias /cgi-bin/ /var/www/vhosts/domain.com/cgi-bin/
Action php52-cgi /cgi-bin/php-cgi
AddHandler php52-cgi .php

20. Ask Plesk to reconfigure the domain

/usr/local/psa/admin/bin/httpdmng –reconfigure-domain domain.com

Reference:
http://mossiso.com/2009/09/02/multiple-php-instances-with-one-apache.html
http://kb.parallels.com/en/430