Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/articles/php-tutorials/)
-   -   Install/Run PHP4 and PHP5 Together (http://www.go4expert.com/articles/install-run-php4-php5-t2948/)

pradeep 10Feb2007 13:08

Install/Run PHP4 and PHP5 Together
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 "http://us4.php.net/get/php-${VERSION}.tar.bz2/from/this/mirror"
 tar -xjvf php.tbz2
 rm -f php.tbz2
 wget http://choon.net/opensource/php/php-${VERSION}-mail-header.patch
 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., "php5install.sh", 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.

All times are GMT +5.5. The time now is 02:25.