Here are some notes on installing PHP 5.3.6 (the latest version at time of writing) with Homebrew, an awesome package manager for OS X.

  1. If you haven’t done so already, install Hombrew. Check out the installation instructions over at the Hombrew wiki.

  2. Grab the latest copy of my PHP brew and copy it into your Homebrew Formula directory.

     curl -O https://github.com/ampt/homebrew/raw/php/Library/Formula/php.rb
     mv php.rb `brew --prefix`/Library/Formula
    
  3. To see the available options:

     brew options php
    
  4. Run the brew install php command. The following will install PHP with Apache and MySQL support.

     brew install php --with-apache --with-mysql
    

    Or if you want to install php-fpm:

     brew install php --with-fpm
    

Once thats done you should be good to go.

Note: Depending on your setup you may want to add the following to your .bash_profile:

echo 'export PATH='`brew --prefix php`'/bin:$PATH' >> .bash_profile

This will ensure that BASH has the correct path to the PHP you just installed.

Bonus Points: xdebug

Install xdebug (there’s a brew for that) a great tool to help debug your PHP code:

brew install xdebug