Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just upgraded my MBP to Snow Leopard (OS X 10.6), which took PHP to 5.3

This is great, except I use my MBP as my development machine and I use a lot of PHP libs and frameworks (namely CakePHP 1.2) which are not compatible at the moment with PHP 5.3. CakePHP in particular does not have a stable version for PHP 5.3 so its not a matter of upgrading the framework (and the production servers are under PHP 5.2 anyway.)

Is there a way to install PHP 5.2.9 alongside PHP 5.3 and then using httpd.conf or .htaccess tell Apache which version of PHP to use for a particular directory?

Alternatively is there a way to do this with MacPorts?


share|improve this question
up vote 9 down vote accepted

Mark Story has written a great article on how to achieve this. He is a CakePHP core developer, and uses this setup for work and cakephp development.

share|improve this answer
Yes he did! I had a small back and forth with Mark about this and have adapted his shell script to do switching between just PHP 5.3 and PHP 5.2.10. Using MacPorts' built in ability to activate/deactivate the environments makes this a snap, and its done in a 'mac' way. – Darren Newton Sep 9 '09 at 11:41
Originally I was going to try and do this using FastCGI following this (rather good) article:… Unfortunately I couldn't get PHP 5.3 to compile and running FastCGI under suexec (which I am not familiar with) made me a little nervous, so Mark Story's solution above felt more comfortable. – Darren Newton Sep 9 '09 at 11:44

I suggest downloading the PHP distribution you would like as source, and then set ./configure parameter options (see ./configure --help) so the software is installed either in a unique location or with the version number appended to the name. This way when you run make install the PHP 5.3 install is not overwritten. Finally setup a separate suffix mapping in Apache which routes to version you'd like, or override the default PHP mapping for the VirtualHost or Directory stanza where your scripts are located.

share|improve this answer
How would Xdebug and APC play with this setup? – Darren Newton Jan 14 '10 at 13:45

I am maintaining some build scripts as part of the Homebrew project that will let you do just that (at least the installation part) very easily. I blogged about it -

share|improve this answer
You guys using DarwinPorts and/or Fink, should really check out Homebrew. – Eno Mar 28 '12 at 15:37

One option would be to install different version of something like MAMP and then tinker with each install individually.

share|improve this answer

Here is another suggestion:

share|improve this answer
I had already name checked this article in my comments to predominant. Thanks though. – Darren Newton Jan 13 '10 at 12:53

This is my own write up from many months back:

Very easy and clean solution. Hope that helps.

share|improve this answer
Your link doesn't work. So, pretty much a useless answer! – Lee Taylor Dec 23 '12 at 22:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.