PHP being the dominant language on the Internet, Many cpanel customers used multiple versions of PHP 5.2, 5.3, 5.4 and 5.5 for their customer php application. In Cpanel, CloudLinux Multiple cPanel versions plugin providing option to select among a large number of PHP extensions. Quite often one user needs one extension while the other customer needs another.

When using different software, you may need to use an older version of PHP while running a newer version of PHP on a different domain. For example: You can have PHP 5.4 for the site in public_html and if you want to use PHP 5.3 in a subdirectory then install manually multiple php version and update add handler in .htaccess file.

multiple php version

Manually install multiple php version in cpanel.

Use the following Steps to install multiple php versions.

#cd /usr/local/src

Download php tar file which version you want to install.


#tar -zxvf php-5.3.28.tar.gz

#cd php-5.3.28

You can get the configuration options for the new install from the existing installation using the following command

php -i | grep configure | sed ‘s/Configure Command => //g’|sed “s/’//g”

Make sure to remove the configuration parameter for apxs ie –with-apxs2=/usr/local/apache/bin/apxs and modify the installation path –prefix and php.ini config file location. Example, –prefix=/usr/local/php53  –with-config-file-path=/usr/local/php53/lib –with-config-file-scan-dir=/usr/local/php53/lib/php.ini.d

#./configure –disable-pdo –enable-bcmath –enable-calendar –enable-ftp –enable-gd-native-ttf –enable-libxml –with-mysqli=/usr/bin/mysql_config –enable-mbstring –enable-sockets –enable-wddx –enable-zip –prefix=/usr/local –prefix=/usr/local/php53 –with-config-file-path=/usr/local/php53/lib –with-config-file-scan-dir=/usr/local/php53/lib/php.ini.d –with-curl=/opt/curlssl/ –with-freetype-dir=/usr –with-gd –with-imap=/opt/php_with_imap_client/ –with-imap-ssl=/usr –with-jpeg-dir=/usr –with-kerberos –with-libdir=lib64 –with-libexpat-dir=/usr –with-libxml-dir=/opt/xml2/
–with-mcrypt=/opt/libmcrypt/ –with-mhash=/opt/mhash/ –with-mysql=/usr –with-mysql-sock=/var/lib/mysql/mysql.sock –with-openssl=/usr –with-openssl-dir=/usr –with-pcre-regex=/opt/pcre –with-pic –with-png-dir=/usr –with-tidy=/opt/tidy/ –with-ttf –with-xmlrpc –with-xpm-dir=/usr –with-xsl=/opt/xslt/ –with-zlib –with-zlib-dir=/usr


#make install

Once the installation is completed, confirm the version by using the command.

#/usr/local/php53/bin/php-cgi -v

PHP 5.3.28 (cgi-fcgi) (built: May 29 2014 15:40:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

Finally copying php.ini from build folder.

#cp php.ini-production /usr/local/php53/lib/php.ini

Now you should configure it for web server access through specifying the new PHP handler for php file. AddHandler specifically is meant to communicate with the server. It assigns or “maps” a handler to the file extension you specify, giving the server instructions on how to deal with it. You can enable SuPHP with newly builded php.

Open suphp.conf file.

#vi /opt/suphp/etc/suphp.conf

update this line in bottom of handler section ( [handlers] ;Handler for php-scripts )

application/x-httpd-php53=”php:/usr/local/php53/bin/php-cgi ”

Finally update suphp add handler on php.conf file.

#vi /usr/local/apache/conf/php.conf

update inside for root directory <Directory />

suPHP_AddHandler application/x-httpd-php53


<Directory />
suPHP_AddHandler application/x-httpd-php53

Restart Apache webserver.

#/etc/init.d/httpd restart

Thats all!!! you can add the following handler config in your account folder .htaccess file to user php 5.3.

AddHandler application/x-httpd-php53 .php


If you want to change server wide php version to 5.3 instead of current php version then you should update AddType in /usr/local/apache/conf/php.conf file.

AddType application/x-httpd-php53 .php5 .php4 .php .php3 .php2 .phtml

Use the same method to install multiple php version in your cpanel server.



Get Free cPanel Knowledge Base

Thank you for subscribing.

Something went wrong.

5.00 avg. rating (97% score) - 2 votes