Howto run PHP 4 and 5 on Cpanel

This information is helpful for hosting companies that want to run PHP 4 & 5 on the same cPanel server. After this, Hosting costumers / cPanel users should choose what version of PHP will they use on theirs scripts.

You should consider some implications on your server performance, but webhosts are using because they don't need two server to run the different PHP versions for different costumers.

How to run PHP 4 and 5 on the same Cpanel server

1. Login to you cPanel server as root using ssh

2. Check the compiler and remove and re-create cpphpbuild directory

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

3. Download PHP5 and extract it
# wget http://us2.php.net/get/php-5.2.4.tar.gz/from/this/mirror
# tar zfx php-5.2.4.tar.gz
# cd php-5.2.4

4. Download, build and install php5.gen.cpanel
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

5. Now you should move the files and finish 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


6. Configure httpd.conf file, save and exit.
# nano /usr/local/apache/conf/httpd.conf


Find the section index.php5 that is 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. Restart apache service
# service httpd restart

Now you should inform you webhosting costumers that they should use the extension .php5 if they want to use PHP5 on theirs scripts, all the other php extensions will be parsed by php4 instllation.

Credits: http://forums.defenderhosting.com/showthread.php?t=2103 (some information taken).

0 Comments: