Server Administration & Management

How to running PHP 4 and PHP 5 on the same cPanel

Here is following process to install and run on the same server php 4 and 5. Users will be allowed to choose what version to use for their scripts.
Although I personally don’t recommend this as it has many performance implications it’s something that small webhosts use so that they don’t have to have different servers for different php versions.

1. Compiler check

# /scripts/checkccompiler
# rm -rvf /home/cpphpbuild
# mkdir /home/cpphpbuild
# cd /home/cpphpbuild

2. Download and extract php

# wget http://us2.php.net/downloads.php
# tar -xzf php-5.2.4.tar.gz
# cd php-5.2.4

3. Configure and build the php installation (credits go to elix for an excellent work)

# echo “#define HAVE_SENDMAIL 1? >> /home/cpphpbuild/php-5.2.4/main/php_config.h
# wget http://www.elix.us/tutorials/php5.gen.cpanel
# chmod 700 php5.gen.cpanel
# ./php5.gen.cpanel
# make
# make install

4. Moving the files and finishing the configuration

# cp -f /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
# chown root:wheel /usr/local/cpanel/cgi-sys/php5
# cp -p /home/cpphpbuild/php-5.2.4/php.ini-recommended /usr/local/php5/lib/php.ini
# chown root.root /usr/local/php5/lib/php.ini
# chmod 644 /usr/local/php5/lib/php.ini
# echo “cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode” >> /usr/local/php5/lib/php.ini

5. Now we have to add a few lines to the httpd.conf file

# vim /usr/local/apache/conf/httpd.conf

6. Add in the section – “index.php5″ before index.php4 and Add after “AddType application/x-httpd-php .phtml”

Action application/x-httpd-php5 “/cgi-sys/php5″
AddHandler application/x-httpd-php5 .php5

7. Test the installation

# service httpd configtest

8. If you get any errors please check that you done all the steps properly. If everything is ok you can now restart apache.

# service httpd restart


October 29, 2012 - Posted by | Apache, PHP | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: