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?

4 Answers
4

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.

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.

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.
–
Reece45Jul 13 '10 at 15:08