views:

134

answers:

4

I'm developing for a bunch of sites on my local machine. Some of those sites ultimately run on php5.3, and some run on php5.2. Is there a way I can setup virtual hosts to use different versions of php for each?

+1  A: 

I am use a denwer. It is a local server. Denwer can be installed many times on one machine or USB. I have 2 denwers on my computer. One with php 5.2. Second with php 5.3.

Alexander.Plutov
Wouldn't they need to run on different ports?
AlReece45
+5  A: 

You should be able to manually compile both versions of PHP to separate directories and setup PHP with FastCGI for each website. FastCGI will give you comparible performance to mod_php on apache.

You could also set each one up with CGI. Its a lot slower, but then you can't see how modules like APC will help your code or used shared memory or persistent connections reliable (they will work for just one request)

If that doesn't work, you can make a second install of your webserver, configure it to run on a different port, and then set up your other webserver to act as a proxy, forwarding requests to a specific virtual host to the other webserver.

AlReece45
good call. thanks dude.
Cory Collier
A: 

Either you do as per the above and use different versions of PHP using FastCGI on your machine. But since it's for development, you could also use ie. VirtualBox or VMware server and create 2 virtual machines, one with PHP 5.2 and one with 5.3 (or you could create even more, one per project - that's how I would do it in fact :p).

Possible benefits : you could use the OS - and the same software versions of ie. apache / mysql - that is used on your external host (that's why I would prefer one VM per project). This might also be beneficial when debugging later on.

wimvds
Seems like a lot of overhead for just a developers box. It'd probably be better for him to set up a development website on the production box if the VM was simply trying to replicate it.I think it would also make it harder write code resistant to simple changes (like file paths). Often, this hard coded information spreads into the database or other areas. Not everyone knows that all these things should start out in a configuration file. If your code really has some areas that commonly break between systems, write a script to test it. It'll save more time than the overhead of the VMs.
AlReece45
A: 

You could try to run php as cgi. I don't know if it works, you have to pass different php.ini locations to the cgi for things like different temp dirs. Wouldn't recommend it on a production machine.

vasquez