Steps to install PHP 5.2 and PHP 5.3 together on cPanel ServerWe may need 2 versions of php for different website in a server. cPanel does not provide option to run both versions by default. For this you need to compile PHP 5.2 manually.
Please follow the steps to enable PHP 5.2 on your server.
1. Download and unzip PHP 5.2:
mkdir /usr/local/customphp52
cd /usr/local/customphp52
wget http://museum.php.net/php5/php-5.2.17.tar.gz
tar -zxvf php-5.2.17.tar.gz2. Configure PHP
./configure --prefix=/usr/local/php52 --enable-cgi --enable-bcmath\
--with-mysql=/usr/bin -with-libdir=lib64\ --with-gd
make
make install3. Add the handlers to Apache config.
vim /usr/local/apache/conf/includes/pre_virtualhost_global.confAdd this:
Action application/x-httpd-php52 /cgi-sys/php52
AddType application/x-httpd-php52 .php524. Distill Apache.
/usr/local/cpanel/bin/apache_conf_distiller --update5. Create the following file so cPanel will skip .htaccess scan
touch /var/cpanel/easy_skip_update_php_mime_types6. Create the following file to detect PHP 5.2
vi /usr/local/cpanel/cgi-sys/php52You need to add the following content.
#!/bin/sh
exec /usr/local/php52/bin/php-cgi7. Correct the permissions.
chown root:wheel /usr/local/cpanel/cgi-sys/php52
chmod +x /usr/local/cpanel/cgi-sys/php528. Copy the php.ini file.
cp -pr /usr/local/customphp52/php-5.2.17/php.ini-recommended /usr/local/php52/lib/php.ini9. Create a symlink to the current php binary file.
ln -sf /usr/local/php52/bin/php-cgi /usr/local/bin/php10. Restart Apache.
service httpd restartNow if you wish to use PHP5.2 just create a .htaccess file in the required domains public_html and add the following in it.
AddHandler application/x-httpd-php52 .phpFrom now onwards if you wish to compile any module to PHP 5.2 please use the corresponding phpize & configure command.
phpize – /usr/local/php52/bin/phpize
php-config – ./configure –with-php-config=/usr/local/php52/bin/php-configCheers!!!