1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Install/Run PHP4 and PHP5 Together

Discussion in 'PHP' started by pradeep, Feb 10, 2007.

  1. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    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.
    PHP:
     #!/bin/sh
     # PHP5 CGI Installer for cPanel/WHM Servers
     
     
    VERSION=5.0.4
     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
     
     PHP
    =/usr/local/bin/php
     CFG
    =`$PHP -i | grep configure | sed "s/'//g" | sed "s/\.\/configure \(.*\)--with-apxs.*apxs \(.*\)/\1 \2/"`
     
    CFGLINE="${CFG##* => } —prefix=/usr/local/php5 —exec-prefix=/usr/local/php5 —program-suffix=5 —enable-force-cgi-redirect —enable-discard-path"
     
     
    ./configure $CFGLINE
     make
     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"" ]
     
    then
     
    echo "Include /usr/local/apache/conf/php5.conf" >> /usr/local/apache/conf/httpd.conf
     
    echo "Your all set to restart your apache now. "
     
    fi
    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.
     

Share This Page