x2o

Member
May 11, 2005
22
0
151
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:
 

Zaf

Well-Known Member
Aug 22, 2005
117
0
166
x2o said:
Hi I was wondering if it's possible to have php4 and 5 on the server at the same time?
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.
 

Blue|Fusion

Well-Known Member
Sep 12, 2004
377
0
166
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
 
Last edited:

dhabets

Well-Known Member
Dec 31, 2001
68
0
306
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
 

astopy

Well-Known Member
Apr 3, 2003
166
0
166
cPanel Access Level
Root Administrator
Blue|Fusion said:
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.
Your script works great, thanks for posting it :)
 
N

NoAgendas

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

spiralfive

Member
Jan 23, 2006
10
0
151
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"
 

chris8lunch

Well-Known Member
May 27, 2006
160
0
166
Blue|Fusion said:
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
How do I do this? Can someone explain?