Homebrew is a package manager that makes it easy to install UNIX tools which don't come with OS X. Using the Homebrew package manager provides a great amount of control over the software installed on an OS X system, and it can be used to provide missing elements to run Drupal directly on OS X as a development environment.
I didn't set out to use Homebrew. I simply wanted to use wget instead of curl. I had no idea that would lead me to completely change my development setup.
The wget command doesn't come with OS X. One can download the source and compile it or find a binary somewhere on the web, neither of which really sounded so appealing. So I decided to try an alternative: Homebrew. Homebrew is a package manager that makes it easy to install UNIX tools that don't come with OS X. Using to install wget was really simple. In fact, wget must be a popular package because Homebrew uses it as their first example on their homepage.
While I was at it, what else could I install? I removed the old Git binary I'd downloaded a year or two ago and never upgraded. Entering 'brew install git' installed the latest version. A simple 'brew install drush' and I had drush 5.0 installed. To upgrade those or any other brew installed packages all it takes is a 'brew update; brew upgrade'.
My development setup for a long time has been Linux on Virtualbox and I haven't been entirely satisfied with it. Everything on the Linux side is solid. No problems at all there. The issue has been with how I was running Linux on OS X. The virtualization definitely had some overhead and was using about 25% of my RAM. Virtualbox was also using single files as its filesystem, so backing it up was not efficient. I could see Virtualbox was consuming about 12-16% CPU even when the Linux OS was idle and I knew that was impacting my battery life.
Could Homebrew do what I needed to run my LAMP stack on OS X instead and just eliminate Virtualbox? MAMP does this by providing its own Apache, MySQL and PHP but OS X already has these except for MySQL. 'brew install mysql' fixed that. This time I actually used 'brew -v install mysql' so I could watch the progress. That was the easy part. The configuration changes to default OS X settings were a little more difficult. If you are not comfortable on the command line and haven't tweaked Apache before, you might want to use MAMP or some other packaged stack.
I tried to minimize changes to OS X defaults so to have a the least possible impact on the rest of the system and concentrate changes so that if anything breaks on upgrades, I know where to look. Performance and battery life is substantially better.
Drupal on OS X using Homebrew Recipe
Get homebrew http://mxcl.github.com/homebrew/ . Follow the 'Install Homebrew Today!' link for the ruby command to run to get it installed. You will need to run that command as a user with Administrator privileges. As I said, I removed my old Git and reinstalled it with brew. If you don't have Git installed, start with that. You can skip wget if you want. Open Terminal and run these commands.
brew install git
brew install wget
brew install drush
brew -v install mysql
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Use sudo for admin privileges.
ln -s /tmp/mysql.sock
Apache config changes
In System Prefs, turn on Web Sharing to enable User web directories. ~/Sites will be used by default.
Use sudo for admin privileges.
Back up /etc/apache2/httpd.conf
chmod u+w httpd.conf
Edit httpd.conf as follows:
Uncomment the following lines.
#LoadModule php5_module libexec/apache2/libphp5.so
Add the following line after the Include line above.
Replace with your username. Adding this Include line will give you a directory to use for vhost configuration files. I used the .vhost extension so I could remove vhosts by not using that extension.
chmod u-w httpd.conf
Create your ~/Library/Vhosts directory and add your vhost configuration files there. Using Apache virtualhosts is optional but the above recipe will allow it.