The first 2 versions of PHP 5 had been released and even Beta 3 and the call on pear-dev had to come, until I found time to install a version of PHP 5. One of my most important requirements was to have a copy of PHP 4 and 5 running parallel on 1 maschine. Christian Stocker gave me the important advice to simple run 2 Apache instances with different config files.
This is not a heavy issue to manage, but since i did not find a how-to on it, I would like to provide some information, to make usage of PHP 5 suitable for unexperienced users too.
1. The idea:
The idea is very simple. I wanted to have 2 versions of PHP (4.3.4 and 5.0beta3) running together on 1 maschine, both as Apache 1.3 modules.
2. Compiling PHP:
I had a PHP 4.3.4 running on my devbox and compiled a PHP 5 version in addition. This can be managed in a bloody simple way. Download a copy of PHP 5, unpack the archive to any directory. Copy the './configure' statement from your installed PHP version and exchange/create the prefix option, e.g. '--prefix/usr/php5' and change the '--with-config-file-path' to a different location (e.g. '/etc/php5').
Run the './configure' statement inside the unpack directory using './configure <your options>'. You can get a complete list opf PHP 5 supported option with './configure --help'.
PHP 5 make files had been created successfully (most errors shouls result from version conflicts of libraries and header files, you can easiely solve this by installing or compiling new versions of the required packages/development-packages). Now you should run the 'make' statement and get a coffee, during your first PHP 5 compile...
3. Creating Apache configuration
We want to run 2 different modules with a very similar API definition, so we need 2 different Apache (I used 1.3 branch, but 2.0 should work fine, too) instances. You can achieve that with 2 configuration files.
Easiest way to get started is copiing your current Apache configuration (usually located in '/etc/apache/' or '/etc/httpd/' (some wired distributions even have itt in '/usr/local/httpd/etc/') 'httpd.conf' to 2 new files in the same directory and call them (e.g.) 'httpd.conf.php4' and 'httpd.conf.php5'.
Now start editing the 'httpd.conf.php4' file. You can set up a completely different configuration, if you like, but in this case I will show you only the neccessary changes to divide the 2 Apache instances as clean as possible.
The listed lines should either contain unique or common values (between '.php4' and '.php5' config file), whhat I noted there in comments. Creating the '.php4' file from the '.php5' one or the other way round is more or less a simple replace action.
-- httpd.conf.php4 --
# Unique lock file
LockFile /var/lock/apache-php4.lock
# Very important for init script
# Unique process ID file
PidFile /var/run/apache-php4.pid
# Unique scoreboard file
ScoreBoardFile /var/run/apache-php4.scoreboard
# Unique port number
Listen 80
# Common document root
DocumentRoot /var/www
# The most important lines in both config files are the following:
# For the .php4 file
LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
# For the .php5 file
# LoadModule php5_module /usr/lib/apache/1.3/libphp5.so
-- httpd.conf.php4 --
You can now try to run those apache instances using the commands
$ apache -f /etc/>apache</httpd.conf.php4
$ apache -f /etc/>apache</httpd.conf.php5
(or the other way around). Maybe your distribution uses another name for the apache binary, such as httpd.
Doing a
$ ps -A
should show you 2 times the number of minimum processes you provided in the httpd.conf.\* files. Open a browser and check the used ports for responses. Here we go, PHP 5 is running. You can easily test your scripts with both PHP versions calling the provided sockets in dirfferent browser-tabs or -windows.
4. Startup (init) for Debian
My GNU/Debian Woody box uses the usual start-up (init) script to run apache during boot process. The process to run 2 Apache instances is the same as for 'httpd.conf' files. Go to your distribution specific init directory (debian uses '/etc/init.d/') and copy the actual startup script (named 'apache' on Debian) into 2 new files (I used 'apache-php4' and 'apache-php5').
The specific configuration changes in this file run parallel to those in 'httpd.conf'. Here is my PHP 5 solution including some comments:
-- apache-php5 --
#! /bin/bash
#
# apache Start the apache HTTP server.
#
NAMEapache
PATH/bin:/usr/bin:/sbin:/usr/sbin
SUEXEC/usr/lib/apache/suexec
# Add PHP version specific pid file (set in httpd.conf.\*)
PIDFILE/var/run/$NAME-php5.pid
# Your PHP version specififc config file
CONF"/etc/apache/httpd.conf.php5"
DAEMON/usr/sbin/apache
APACHECTL/usr/sbin/apachectl
trap "" 1
export LANGC
export PATH
test -f $DAEMON || exit 0
test -f $APACHECTL || exit 0
# ensure we don't leak environment vars into apachectl
APACHECTL"env -i LANG${LANG} PATH${PATH} $APACHECTL"
if egrep -q -i "^[[:space:]]\*ServerType[[:space:]]+inet" $CONF
then
exit 0
fi
case "$1" in
start)
echo -n "Starting web server: $NAME"
# Add '-- -f $CONF' to take configuration in respect
# This might be a bug in standard Debian ini file here, cause $CONF is defined,
# but normaly not used.
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- -f $CONF
;;
stop)
echo -n "Stopping web server: $NAME"
# Add '-- -f $CONF' to take configuration in respect
start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON -- -f $CONF
;;
reload)
echo -n "Reloading $NAME configuration"
# Add '-- -f $CONF' to take configuration in respect
start-stop-daemon --stop --pidfile $PIDFILE --signal USR1 --exec $DAEMON -- -f $CONF
;;
reload-modules)
echo -n "Reloading $NAME modules"
start-stop-daemon --stop --pidfile $PIDFILE --oknodo --retry 30
# Add '-- -f $CONF' to take configuration in respect
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- -f $CONF
;;
restart)
$0 reload-modules
exit $?
;;
force-reload)
$0 reload-modules
exit $?
;;
\*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|reload-modules|force-reload|restart}"
exit 1
;;
esac
if [ $? == 0 ]; then
echo .
exit 0
else
echo failed
exit 1
fi
-- apache-php5 --
Done. You can now start / stop / ... those apaches independently using '/etc/init.d/apache-php5 >command<'.
If you liked this blog post or learned something, please consider using flattr to contribute back: .
Fields with bold names are mandatory.
chregu
Aaah, yes. the init and config scripts with the lock et al. files have to be adjusted ;) Was that the problem that it didn't work in the first place?
Link to commentToby
Not really. The problem was an IRCG module I had included within my php.ini. That should not have mattered at all, but it was the reason my PHP4 allways crashed... :(
Link to commentManuzhai
Will it not be possible to have PHP 4 and 5 running in the same server as different MIME-types? Now that would help in that my hoster could install PHP 5 so that I can just use .htaccess to use 5 instead of 4 in one directory...
Link to commentToby
I guess, since most of the API between Apache and PHP looks similar in Version 4 and 5 it's not possible to run both as a module in 1 server.
Link to commentIndeed it should be possible to run 1 version as a module, the other one as CGI interpreter.
Jannis
machine...
Link to commentJohn Gray
This works well with Apache 2.0, although I didn't need the LockFile, just the PID. I combined it with Coggeshall's mod_proxy setup (http://wiki.coggeshall.org/37.html) for a pretty slick solution. Thanks for writing this up.
Link to commentromain
Hi,
Link to commentwith WAMP5 you can now have PHP 5.0.0 and PHP 4.23.8 on the same Windows server...
programming help
Until now, using php4 and not much want to move to php5 - I was completely satisfied 4
Link to commentmidi files downloads
Sorry, that is only for web access. Checkouts can be done like this:
Link to commentsvn co svn://phpugdo.de/PDV
That is because I run Lighttpd and not Apache. ;)
aspiffpek
Hi guys!
Link to commentI am here to tell you about this cool site I found!
It's called tweetforum , and it's a forum that tweets every post you write!
Check us out at http://tweetforum.com
or chekout our awesome twitter cloud, and be sure to follow us!
http://twitter.com/flippro - My personal twitter account.
http://twitter.com/tweetsforum - TweetForum's main account-Syndicates all posts
http://twitter.com/tweetforummusic - Tweets new music
http://twitter.com/tweetnewsforum - Tweets breaking news from our forum
http://twitter.com/tweetforumufo - Tweets breaking U.F.O news and discussion
http://twitter.com/tweetforumvideo - Tweets the newest web-videos/movies/and episodes
http://twitter.com/tweetforumsport - Tweets the latest in sports news
http://twitter.com/tweetforument - Tweets the latest entertainment news
http://twitter.com/tweetsalemarket - Tweets the marketplace
http://twitter.com/bitcoinforum - Tweets about ##Bitcoin investments
http://twitter.com/forumstocks -Tweets breaking stockmarket news and discussion.
http://twitter.com/tweetforumforex -Tweets Forex exchange news.
http://twitter.com/estateupdates - Tweets Realestate and property listings
http://twitter.com/learntwtforum - The latest twitter news
http://twitter.com/tweetforumbiz- Tweets new businesses and ideas for entrepreneurs.
http://twitter.com/marketingforum7 - Tweets marketing news and discussions
http://twitter.com/bloggForum - Tweets fresh blogging jobs for extra cash $
http://twitter.com/tweetforumwah -Tweets real Work at Home jobs that pay.
http://twitter.com/tweetforumweb - Tweets web developer news
spispadipsdep
Hey good post! <a href=http://www.alibaba.com/member/us104698538.html>mill valley sheepskin & leather Co.</a>
Link to commentodold
<a href=http://angelsofjustice.clan.su/index/8-121>гордунни WOW</a>
Link to commentglovita
<a href=http://angelsofjustice.clan.su/forum/0-0-1-3-187>гильдия вов WOW</a>
Link to commentRitik
What an amazing blog. I have found this blog very interesting because I have gotten the most read information. This blog help me out otherwise I don’t know how much time I have to spend for getting right information..
Link to comment<a href="http://partytimeliquor.com/">Liquor Store St. Paul</a>
www.theboysshopping.com
I am interested in this topic and would like to find out some more information as my friend need information on this topic
Link to commentslendertone abs belt
What an amazing blog. I have found this blog very interesting becaus
Link to commentFree Run 2
ed in this topic and would like to find ou
Link to commentBlack Shoes
Hello, hello, ah, Gu reporter, right, I Zhao Qingming, where are you? Good, good.
Link to commentBlack Shoes
Hello, hello, ah, Gu reporter, right, I Zhao Qingming, where are you? Good, good.
Link to commentRunning 2
Mackie mother hesitated, what is it? If you know ask him? S pregnant when the
Link to commentEmpigmigo
табуретушка.рф г
Link to comment<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно видео</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>русское порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно русскии</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно съ</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть онлайн порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно фильмы</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно фильмі</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть порно бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть бесплатное порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатно смотреть бесплатное порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно фото</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно онлайн бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно онлайн бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>гиг порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>скачать порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно ролики</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть порно онлайн бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно онлайн смотреть онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное порно онлайн смотреть бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно онлайн фильмы</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно фильмі онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть порно фильмы</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно фильмі смотреть</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно зрелых</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно зрел</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>русское порно онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно видео онлайн</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно видео бесплатно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатное видео порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>бесплатно порно видео бесплатное</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно игры</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>смотреть порно видео</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно +без регистрации</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно мама</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно бeз регистрации</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно секс</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>домашнее порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>домашние порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно русское смотреть</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>лучшее порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>краще порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>лучше порно</a>
<a href=http://xn--80aacqz8alegd9c.xn--p1ai/>порно рассказы</a>
<a href=http://табуретушка.рф/>порно</a>
<a href=http://табуретушка.рф/>порно онлайн</a>
<a href=http://табуретушка.рф/>смотреть порно</a>
<a href=http://табуретушка.рф/>порно видео</a>
<a href=http://табуретушка.рф/>порно бесплатно</a>
<a href=http://табуретушка.рф/>бесплатное порно</a>
<a href=http://табуретушка.рф/>бесплатное порно бесплатно</a>
<a href=http://табуретушка.рф/>русское порно</a>
<a href=http://табуретушка.рф/>порно русскии</a>
<a href=http://табуретушка.рф/>порно съ</a>
<a href=http://табуретушка.рф/>смотреть онлайн порно</a>
<a href=http://табуретушка.рф/>порно фильмы</a>
<a href=http://табуретушка.рф/>порно фильмі</a>
<a href=http://табуретушка.рф/>смотреть порно бесплатно</a>
<a href=http://табуретушка.рф/>смотреть бесплатное порно</a>
<a href=http://табуретушка.рф/>бесплатно смотреть бесплатное порно</a>
<a href=http://табуретушка.рф/>порно фото</a>
<a href=http://табуретушка.рф/>порно онлайн бесплатно</a>
<a href=http://табуретушка.рф/>бесплатное порно онлайн</a>
<a href=http://табуретушка.рф/>бесплатное порно онлайн бесплатно</a>
<a href=http://табуретушка.рф/>гиг порно</a>
<a href=http://табуретушка.рф/>скачать порно</a>
<a href=http://табуретушка.рф/>порно ролики</a>
<a href=http://табуретушка.рф/>смотреть порно онлайн бесплатно</a>
<a href=http://табуретушка.рф/>бесплатное порно онлайн смотреть онлайн</a>
<a href=http://табуретушка.рф/>бесплатное порно онлайн смотреть бесплатно</a>
<a href=http://табуретушка.рф/>порно онлайн фильмы</a>
<a href=http://табуретушка.рф/>порно фильмі онлайн</a>
<a href=http://табуретушка.рф/>смотреть порно фильмы</a>
<a href=http://табуретушка.рф/>порно фильмі смотреть</a>
<a href=http://табуретушка.рф/>порно зрелых</a>
<a href=http://табуретушка.рф/>порно зрел</a>
<a href=http://табуретушка.рф/>русское порно онлайн</a>
<a href=http://табуретушка.рф/>порно видео онлайн</a>
<a href=http://табуретушка.рф/>порно видео бесплатно</a>
<a href=http://табуретушка.рф/>бесплатное видео порно</a>
<a href=http://табуретушка.рф/>бесплатно порно видео бесплатное</a>
<a href=http://табуретушка.рф/>порно игры</a>
<a href=http://табуретушка.рф/>смотреть порно видео</a>
<a href=http://табуретушка.рф/>порно +без регистрации</a>
<a href=http://табуретушка.рф/>порно мама</a>
<a href=http://табуретушка.рф/>порно бeз регистрации</a>
<a href=http://табуретушка.рф/>порно секс</a>
<a href=http://табуретушка.рф/>домашнее порно</a>
<a href=http://табуретушка.рф/>домашние порно</a>
<a href=http://табуретушка.рф/>порно русское смотреть</a>
<a href=http://табуретушка.рф/>лучшее порно</a>
<a href=http://табуретушка.рф/>краще порно</a>
<a href=http://табуретушка.рф/>лучше порно</a>
<a href=http://табуретушка.рф/>порно рассказы</a>