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:
1 2 3 |
brew tap josegonzalez/php brew update brew install php54 |
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:
1 |
brew info php54 |
Seperate MySQL Installation: Where is the ctl?
I have installed MySQL separately. I added the mysql and mysqldmin to my bash_profile like this:
1 2 |
alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/local/mysql/bin/mysqladmin |
And to start/stop/restart mysql server, I added:
1 |
export mysqlctl=/Library/StartupItems/MySQLCOM/MySQLCOM |
That allows me to do:
1 |
sudo $mysqlctl restart |
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 replies on “Mac OS X Lion: Homebrew, PHP54, MySQL and PEAR”
Masnun,
brew install php54
will do nothing if you don’tbrew tap josegonzalez/php
My mistake, post is updated!
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
My mysql.server points to the mysql installation via brew. I am using the MySQL I manually installed. That’s why I had to export it.
[…] an earlier post I demonstrated how to install PHP5.4 using brew. Today, I required xdebug for debugging purposes […]