Upgrading from php 5.3 to php 5.4 with Macport
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!
Solution 1:
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.