PHP5.4 has been available for sometime now and Macport recently caught up with the release of port php54 but the process of upgrading is not as clear as possible. Even worst for those who are new to maintaining multiple versions of PHP on the same machine.

I am keen on trying out some of the new features in PHP5.4 like traits, new array form etc but falling back on to php5.3 for other compatibility stuff.

So i

sudo port install php5+ (all the variants, apache2 etc)

Then i tell it what PHP port to use as default

sudo port select --set php php54

Check what version of PHP is active in the terminal using php -v outputs php 5.4.3. But i seem to be having issues with choosing the right non cli version as in the version of the module run by apache etc is still php5.3.12.

Do i have to change the reference to the libphp5 in apache httpd.conf? Any advice on the right workflow for switching between php version on macport greatly appreciated!


I uninstalled and reinstalled everything, but after the fact I saw these: php53-apache2handler @5.3.13 (lang, php, www) & php54-apache2handler @5.4.3 (lang, php, www).

Maybe this used to not be a required step to build your macports MAMP stack, but without it I would get an error trying to start the server. Once I installed it the server worked and used the right version.

sudo port install php54-apache2handler

and then

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php54.so

This appended

LoadModule php5_module        modules/mod_php54.so

to my httpd.conf, and I had to manually remove the old LoadModule as they were conflicting.

| improve this answer | |
  • p. s. I can't wait to be able to stop typing array() whenever I want to pass named parameters into a function!!! – umassthrower Jun 5 '12 at 6:34
  • 1
    Manually setting the right module in apache2 httpd.conf was exactly what i had to do! I also found a gist that explains clearly what needs to be done. – stone Jun 5 '12 at 12:01
  • That's a good find on the gist. – umassthrower Jun 5 '12 at 20:47
  • posted the gist on the macports trac ticket for the creation of php54 for those who dont find that instead of this answer – umassthrower Jun 5 '12 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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