Running PHP 5.3 along with PHP 5.2.X

Pre-requisists:

 

  • MySQL version must be upgraded to 5.1
  • PHP 5.2 version should be atleast 5.2.17

 

Build PHP: 

mkdir /usr/local/buildphp53

cd /usr/local/buildphp53

wget http://us3.php.net/get/php-5.3.13.tar.gz/from/us.php.net/mirror

tar --strip-components=1 -zxvf php-5.3*

./configure --prefix=/usr/local/php53 --enable-cgi --enable-bcmath --enable-calendar --with-mysql=mysqlnd --with-mysqli=mysqlnd and --with-pdo-mysql=mysqlnd --enable (all the modules you need)

           

/usr/bin/make

/usr/bin/make install

 

Extra configurations required

 

For Apache:

 

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

 

Add the following lines to the above file and save

 

Action application/x-httpd-php53 /cgi-sys/php53

 AddType application/x-httpd-php53 .php53

 

 To make cPanel skip the .htacces scan and remove the mime types, do the  following

 

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


touch /var/cpanel/easy_skip_update_php_mime_types 


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

  

Add the following contents to the above file and save 

 

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

 

Setting Permissions

 

chown root:wheel /usr/local/cpanel/cgi-sys/php53

chmod +x /usr/local/cpanel/cgi-sys/php53


 Soft-linking for command-line executions:

 

 ln -s /usr/local/php53/bin/php-cgi /usr/local/bin/php53

 

 Copying php.ini from build folder 

 

mv /usr/local/buildphp53/php.ini-production /usr/local/php53/lib/php.ini

 

 

You need to restart httpd after the configuration 

 

/etc/init.d/httpd restart

 

 Now everything is set. If you want to enable php5.3 for a particular account, create a .htaccess file as mentioned below. 

 

nano -w /home/$username/public_html/.htaccess

 

Add the following line to it

 

AddHandler application/x-httpd-php53 .php

 

 Correct the permissions;

 

chown $username:$username /home/$username/public_html/.htaccess
 

chmod 644 /home/$username/public_html/.htaccess

 

 Things you should remember while installing/enabling a new module to new custom build php 5.3

 

  •   Make sure that you do things related to php5.3 . For eg, if you have to do a “phpize”, you have to do it like this in command-line.

 

/usr/local/php53/bin/phpize

 

  • If you want to run ./configure, select the correct php-config path. See the example given below.

                

./configure  --with-php-config=/usr/local/php53/bin/php-config


 That's all.