Page 1 of 1
running multiple php/mysql versions
Posted: Tue Apr 04, 2006 5:36 am
by jmut
Hi folks,
I am trying to set up on localhost multiple versions between mysql and php.
So for example I could switch with a script or anything to run mysql 4.1 with php5
or mysql 4.0 with php4.0 etc etc.
Are there any tips & tricks you could give to achieving this or should I just straigstforward install stuff. and run some script to switch configuration.
I am running Slackware current btw.
10x in advance for spending time.
Posted: Tue Apr 04, 2006 6:06 am
by Chris Corbyn
The trick with running multiple versions of PHP is to use CGI along with some <Directory> directives in your httpd.conf file.
Install each version of PHP in a different location and ScriptAlias the php-cgi for each one inside <Directory> blocks as per your needs.
You can also run
one version of PHP is a module alongside this.
As for MySQL you need to install multiple versions in different locations again and bind them to different ports. Ahhh... but stop, it's get's better in linux
If this is just for development on localhost then you can totally run everything on standard ports but use different IP addresses. To do that you just alias any private IP's you want to the network interface of your choice:
Code: Select all
ifconfig eth0 192.168.1.1
ifconfig eth0:1 192.168.1.2
ifconfig eth0:2 192.168.1.3
So in your MySQL config you bind to whatever IP you want to and then in your PHP scripts you put that IP down for mysql_connect(). It's all very nifty

Posted: Tue Apr 04, 2006 6:29 am
by jmut
I am not sure if this is what I am trying to do.
The idea is not to run multiple versions etc simultaniuously.
But rather to be able to swtich. So at one point I run under php4.0
And when switch.....refresh...voala php5. (I will keep only one instance of the code....running under different php version.)
with mysql I guess I will have to have several servers (databases) as switching is kind of weird ....will break data and stuff.
Posted: Tue Apr 04, 2006 6:52 am
by Chris Corbyn
jmut wrote:I am not sure if this is what I am trying to do.
The idea is not to run multiple versions etc simultaniuously.
But rather to be able to swtich. So at one point I run under php4.0
And when switch.....refresh...voala php5. (I will keep only one instance of the code....running under different php version.)
with mysql I guess I will have to have several servers (databases) as switching is kind of weird ....will break data and stuff.
Wouldn't you be able to acheive that by running multiple versions alongside. Then change "192.168.1.1" in your address bar to "192.168.1.2" to view it in PHP5 with MySQL 4.1 and Apache 1.3 etc?
That's sort of what I do

Posted: Tue Apr 04, 2006 9:30 pm
by redmonkey
I have roughly 12 versions of PHP, 4 version of MySQL and around 6 version of Apache currently installed on one dev machine. Each one is compiled into it's own directory within /usr/local (i.e. /usr/local/app-version). From that I symlink which ever version I need into /usr/local/app so switching versions is a simple case of updating/changing one symlink.
I'n many cases/versions, you can point different MySQL versions at a single data directory but I wouldn't recommend it, I prefer (and recommend) to keep version specific data directories.
I also keep a library of PHP apache modules again with a symlink pointing to which ever version I require, which means my httpd.conf file just loads the module that the particular symlink is pointing to. For switching/loading of PHP 4 vs 5 you can pass a define in when starting apache (using the -D switch) then within your httpd.conf file have your LoadModule declarations with <IfDefine> blocks.
d11wtq wrote:
Ahhh... but stop, it's get's better in linux
If this is just for development on localhost then you can totally run everything on standard ports but use different IP addresses. To do that you just alias any private IP's you want to the network interface of your choice:
Code: Select all
ifconfig eth0 192.168.1.1
ifconfig eth0:1 192.168.1.2
ifconfig eth0:2 192.168.1.3
So in your MySQL config you bind to whatever IP you want to and then in your PHP scripts you put that IP down for mysql_connect(). It's all very nifty
For what it's worth, both Windows (at least Win2K so presumably XP) and MAC OS X allow binding multiple IPs to a single physical interface.
Posted: Sun Apr 16, 2006 2:13 pm
by asgerhallas
If you don't want to use the CGI-version you can set up two module-versions running along side using two apache servers one of them forwarding to the other by proxy for specified hosts... but then again, that's not for switching, but for running them together.
Posted: Mon Apr 17, 2006 12:05 am
by jmut
Thank you all.
I think symlinks best suite my needs.
What about maintenace?
Posted: Sun May 14, 2006 5:26 pm
by g0nzo
Currently we run PHP 4.3 / MySQL 4.0.x - we would like to run PHP 5 + MySQL 5 both on another port ( 81, for example). The initial concern was ease of maintenance. Will we be able to update automatically using Red Hat's up2date or RPM ?