The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php4 and 5 side by side

Discussion in 'General Discussion' started by x2o, Oct 30, 2005.

  1. x2o

    x2o Member

    Joined:
    May 11, 2005
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Hi I was wondering if it's possible to have php4 and 5 on the server at the same time?

    Or is this not recommended?

    Thanks
    x2o :cool:
     
  2. Zaf

    Zaf Well-Known Member

    Joined:
    Aug 22, 2005
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    16
    Someone posted a step by step to do it at http://forums.cpanel.net/showthread.php?t=45908 just a few hours back. There are quite a few other threads here lately that discuss this issue which you may search within the forums. I'd advise that you do it only if you really need it.
     
  3. Blue|Fusion

    Blue|Fusion Well-Known Member

    Joined:
    Sep 12, 2004
    Messages:
    378
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Cleveland, Ohio
    I also wrote a small script to automatically install PHP5 as a CGI using the same configuration as the already installed PHP4 module. Not really released to public (I just use it on my own servers to keep PHP4 and PHP5 running along side eachother), but here ya go anyway. I'm planning on putting it in my LES program soon, anyway.

    Code:
    #!/bin/sh
    #
    # Copyright (C) 2005 Richard Gannon.  All rights reserved.
    #
    # Author: Richard Gannon
    #
    # This script will install PHP5 as a CGI on a cPanel server using the same configure
    # selections as the already built PHP4.  You can have PHP scripts utilize the PHP5
    # engine by using the .php5 extension.
    #
    # Version 1.1
    #
    ##
    
    PHP_VERSION=5.0.5
    
    WGET=/usr/bin/wget
    GREP=/bin/grep
    TAR=/bin/tar
    AWK=/bin/awk
    
    cd /usr/src
    $WGET -O php.tbz2 http://php.net/get/php-${PHP_VERSION}.tar.bz2/from/this/mirror
    $TAR -xjvf php.tbz2
    rm -f php.tbz2
    $WGET http://choon.net/opensource/php/php-${PHP_VERSION}-mail-header.patch
    cd php-${PHP_VERSION}
    patch -p1 < /usr/src/php-${PHP_VERSION}-mail-header.patch
    rm -f /usr/src/php-${PHP_VERSION}-mail-header.patch
    
    if [ -e /usr/local/bin/php ]; then
    	PHP=/usr/local/bin/php
    else
    	PHP=/usr/bin/php
    fi
    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
    
    PHP5CONF=`$GREP php5.conf /usr/local/apache/conf/httpd.conf`
    if [ "$PHP5CONF" = "" ]; then
    	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
    	echo "Include /usr/local/apache/conf/php5.conf" >> /usr/local/apache/conf/httpd.conf
    fi
    
    CONFIGTEST=`/etc/init.d/httpd configtest | $GREP -m1 Syntax | $AWK '{print $2 }'`
    if [ "$CONFIGTEST" = "OK" ]; then
    	echo "Restarting Apache now..."
    	/etc/init.d/httpd restart
    	echo "Done.  Enjoy PHP5!"
    else
    	echo "There may have been a problem with this installation."
    	echo "Please check the httpd.conf for syntax with '/etc/init.d/httpd configtest'"
    fi
    
    exit 0
     
    #3 Blue|Fusion, Oct 30, 2005
    Last edited: Oct 30, 2005
  4. dhabets

    dhabets Well-Known Member

    Joined:
    Dec 31, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    DataCenter Provider
    chown root:wheel /usr/local/cpanel/cgi-sys/php5

    I'm concerned about using the group wheel, why is that done?

    If I look at the suexec patch:

    * READ THIS BEFORE CONTINUING!!
    *
    * The patch below adds a feature which makes it possible to run "shared"
    * scripts. Suppose you are a systems admin for $large hosting provider and
    * you want to offer your customers some standard scripts. These scripts would
    * cause a security violation based on the uid owner of the script.
    *
    * This patch makes it possible to "trust" a certain user/group. Look below to
    * define the user/group ID.

    So... how does this trust translate?

    What about this vulnerability?

    http://cert.uni-stuttgart.de/archive/bugtraq/2004/06/msg00096.html
     
  5. dhabets

    dhabets Well-Known Member

    Joined:
    Dec 31, 2001
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    DataCenter Provider
    Ok, I guess it's not a problem if you run phpsuexec.
     
  6. astopy

    astopy Well-Known Member

    Joined:
    Apr 3, 2003
    Messages:
    165
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Your script works great, thanks for posting it :)
     
  7. goodmove

    goodmove Well-Known Member

    Joined:
    May 12, 2003
    Messages:
    624
    Likes Received:
    0
    Trophy Points:
    16
    Will this scirpt work correctly with 5.1.4 ??
     
  8. surfdue

    surfdue Member

    Joined:
    May 20, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    WORKS great!
     
  9. goodmove

    goodmove Well-Known Member

    Joined:
    May 12, 2003
    Messages:
    624
    Likes Received:
    0
    Trophy Points:
    16
    Does PHP4 need to be a module (and not CGI) for this script to work?
     
  10. Peteca

    Peteca Registered

    Joined:
    Aug 17, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    how can i apply (step by step) that script?

    Thanks
     
  11. NoAgendas

    NoAgendas Guest

    Will this work with phpsuexec enabled? Also, anyway to do mysql 4x an 5x together?
     
  12. Lizard

    Lizard Member

    Joined:
    Aug 21, 2005
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Works with apache 1.3 ?
     
  13. spiralfive

    spiralfive Member

    Joined:
    Jan 23, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Same questions as everyone else. :)

    1)- Can PHP4 already be installed as an apache module and still use this (PHP5 in CGI/PHP4 in Apache)?

    2)- Will this work with Apache 1.3?

    3)- How do you install the script?

    4)- Will this work with the latest version of PHP5 and PhpSuExec?


    And, if I install this can I use Apache to parse the ".php" files as ".php5" files? That way PHP4 is the default install and users can add the config to their .htaccess files to use hardcoded PHP5 scripts.

    Ex: "xAddType x-mapp-php5 .php"
     
  14. chris8lunch

    chris8lunch Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    160
    Likes Received:
    0
    Trophy Points:
    16
    How do I do this? Can someone explain?
     
Loading...

Share This Page