Mac OS X Lion: Homebrew, PHP54, MySQL and PEAR

In one of my old posts, I noted short documentation on how to get started with the AMP stack on Mac OS X Lion. In that setup, I was using the default PHP and downloaded MySQL from the mysql website. In this post, I am going to describe how I used homebrew to setup my AMP environment with ease!

The Homebrew Magic
Homebrew is a cool tool for Mac OS users. Written in Ruby, this beautiful tool works as a package manager for Mac OS. Unlike Mac Ports or Fink, homebrew takes less space, uses the default os x tools to compile everything to a custom location. This makes life suck less and clutter free!

To install PHP 5.4 branch using homebrew, just issue this command:

PS: If you want to customize the installation (like installing the mysql module by default) add necessary configuration options. Using the “bash-completion” formula from brew, you can hit tabs to see available installation options.

To view information on your PHP 5.4 installation via brew, type in:

Seperate MySQL Installation: Where is the ctl?
I have installed MySQL separately. I added the mysql and mysqldmin to my bash_profile like this:

And to start/stop/restart mysql server, I added:

That allows me to do:

Using PEAR
Homebrew installs all the PEAR packages to “/usr/local/Cellar/php54/5.4.3/lib/php”. So, I added it to my php include_path.

For PEAR to work correctly, we need sudo. If there are tools involved in the pear setup which can be run from command line (eg. phpunit), the binary files are stored in: “/usr/local/Cellar/php54/5.4.3/bin”.

I added the above path to my .bash_profile for convenience 🙂


5 Comments Mac OS X Lion: Homebrew, PHP54, MySQL and PEAR

  1. Rifat Nabi

    Another thing, you don’t need to export ‘MySQLCOM’. MySQL ships with a binary named ‘mysql.sever’. You can just call sudo mysql.server restart

    Reply
  2. Pingback: Debugging with XDebug and PhpStorm on MacOS X | Abu Ashraf Masnun

Leave a Reply

Your email address will not be published. Required fields are marked *