Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Steps to install PHP 5.2 and PHP 5.3 together on cPanel Server  (Read 4765 times)

0 Members and 1 Guest are viewing this topic.

rohitj

  • Guest
Steps to install PHP 5.2 and PHP 5.3 together on cPanel Server
« on: November 23, 2013, 06:51:42 pm »
Steps to install PHP 5.2 and PHP 5.3 together on cPanel Server

We 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.gz


2. Configure PHP

./configure --prefix=/usr/local/php52 --enable-cgi --enable-bcmath\
--with-mysql=/usr/bin -with-libdir=lib64\ --with-gd

make
make install


3. Add the handlers to Apache config.

vim /usr/local/apache/conf/includes/pre_virtualhost_global.conf

Add this:

Action application/x-httpd-php52 /cgi-sys/php52
AddType application/x-httpd-php52 .php52


4. Distill Apache.

/usr/local/cpanel/bin/apache_conf_distiller --update

5. Create the following file so cPanel will skip .htaccess scan

touch /var/cpanel/easy_skip_update_php_mime_types

6. Create the following file to detect PHP 5.2

vi /usr/local/cpanel/cgi-sys/php52

You need to add the following content.

#!/bin/sh
 exec /usr/local/php52/bin/php-cgi


7. Correct the permissions.

chown root:wheel /usr/local/cpanel/cgi-sys/php52
chmod +x /usr/local/cpanel/cgi-sys/php52


8. Copy the php.ini file.

cp -pr /usr/local/customphp52/php-5.2.17/php.ini-recommended /usr/local/php52/lib/php.ini

9. Create a symlink to the current php binary file.

ln -sf /usr/local/php52/bin/php-cgi /usr/local/bin/php

10. Restart Apache.

service httpd restart

Now 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 .php

From 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-config


Cheers!!!