Install/Run PHP4 and PHP5 Together

pradeep's Avatar author of Install/Run PHP4 and PHP5 Together
This is an article on Install/Run PHP4 and PHP5 Together in PHP.
If you have PHP4 working on your server, and have heard that PHP5 may screw up things. Here's how to have both running alongside.
Code: PHP
 # PHP5 CGI Installer for cPanel/WHM Servers
 cd /usr/src
 wget -O php.tbz2 "${VERSION}.tar.bz2/from/this/mirror"
 tar -xjvf php.tbz2
 rm -f php.tbz2
 cd php-${VERSION}
 patch -p1 < /usr/src/php-${VERSION}-mail-header.patch
 rm /usr/src/php-${VERSION}-mail-header.patch
 CFG=`$PHP -i | grep configure | sed "s/'//g" | sed "s/\.\/configure \(.*\)--with-apxs.*apxs \(.*\)/\1 \2/"`
 CFGLINE="${CFG##* => } 用refix=/usr/local/php5 容xec-prefix=/usr/local/php5 用rogram-suffix=5 容nable-force-cgi-redirect 容nable-discard-path"
 ./configure $CFGLINE
 make install
 cp -f php.ini-recommended /usr/local/php5/lib/php.ini
 cp /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
 chown root:wheel /usr/local/cpanel/cgi-sys/php5
 echo "Action application/x-httpd-php5 "/cgi-sys/php5"" > /usr/local/apache/conf/php5.conf
 echo "AddType application/x-httpd-php5 .php5" >> /usr/local/apache/conf/php5.conf
 TEST=`grep php5.conf /usr/local/apache/conf/httpd.conf`
 if [ "$TEST" = "" ]
 echo "Include /usr/local/apache/conf/php5.conf" >> /usr/local/apache/conf/httpd.conf
 echo "Your all set to restart your apache now. "
You'll need to run this code with root permissions of course, save the code as a file e.g., "", CHMOD this file to 644 so it's executable, and then run it at the command line. If you don't know any of these things, you shouldn't be executing this code at all.

Anyway, this should set up PHP5 without interfering without your current setup. The file extension *.php5 will be associated with PHP5.

When the script is done, simply restart Apache. On Linux type setups, it's as simple as "service httpd restart". Checkout the new stuff in PHP5 here.