Running PHP 5.2 and PHP 5.3 on OSX


Tagged as:

With the release of Snow Leopard Mac users have been provided with version 5.3 of PHP already installed and are one commented line away from running it with Apache. Upon installing Snow Leopard I thought "great! shiny new things!", then discovered all my projects down and out from all the shiny goodness. So I needed to get my PHP 5.2 working again. Back on Leopard I'd been using the Entropy PHP package created by Marc Liyange since it comes with all the extensions I needed. Now I didn't want to lose PHP 5.3 as I'd like to play around in it when I have some more spare time. So the ideal situation would be to have both installed and be able to switch between them with as little as an Apache restart.

My current situation is that I'm running PHP 5.2.9 with 5.3 disabled by commenting out the php5 line in httpd.conf. Now to switch back is the hard bit. So far I've not found a nice way to switch back, mainly because I haven't had the time. At the moment if I want to switch back I remove the Entropy package by deleting the folder and uncommenting the line in httpd.conf. In theory there has to be a link between Apache and the Entropy package to make my PHP run (magic?) which hopefully it is possible to disable. As soon as I get the time I'll work out a cleaner solution.

EDIT: Joel Moss (who prompted me to document this in the first place) came up with a solution by wrapping one of your PHP's in a FastCGI wrapper allowing a simple change to the httpd.conf file to switch between the two versions. However the solution proposed by Mark Story seems more up my alley (I'm lazy and running a script suits that trait far better!).

Now I just need the time to get round to actually setting one of these up...