If you don't have homebrew then install it from - http://mxcl.github.com/homebrew/
josegonzalez/php repo to brew, officially recommended.
brew tap josegonzalez/php
PHP with your preferred settings.
Like, mine is
brew install php53 --with-mysql brew install php54 --with-mysql
[In Mountain Lion you will need XQuartz to compile due to drop of
Now, you have both
PHP 5.3 &
PHP 5.4 installed in your machine.
mkdir -p ~/.bin/php-switch cd ~/.bin/php-switch curl -L http://d.pr/8yN8 > php-switch chmod +x php-switch
php-switch to your
.bash_profile the way you preferred.
Now, add the following line to your
LoadModule php5_module /usr/local/lib/libphp5.so
Remove or comment out any other line that contain
You can find your
httpd.conf file path with the following command if you are using the
apachectl -V | grep "httpd.conf"
Finally, you can easily switch between your
PHP versions using -
Or, if you didn't add it to your
- It will use your password to restart apache
- I'm assuming that you are using in-built apache, if not then comment out the last line in the php-switch script
UPDATE: Replaced the broken link (due to github url change) with the updated version by @conradk