The Easy Way to make Drush Work with MAMP

I recently purchased a new MacBook Pro and went through the process of setting up my development environment. Once I got my browsers downloaded (Safari, yeah right), IDE configured, MAMP stack in, and a few other utilities installed I wasn't quite ready to develop on Drupal projects. I still needed to install drush.

PEAR Installation

Drush can be installed via PEAR but if you are in a hurry, want control over your drush source code, or don't want to muck around trying to get PEAR working, you can install it manually.

Manual Installation

Drush's README has instructions on how to install manually but there is a small difference needed to get it working on OSX. Here's what I did to get it working.

Download the drush source code. I grabbed the latest release of drush, 5.9.

cd /usr/local/
curl -O
tar zxvf drush-7.x-5.9.tar.gz

The main hiccup with drush on MAMP is that drush doesn't use the PHP packaged with MAMP and commonly the PHP shipped with OSX is not configured to meet Drupal's requirements. It's possible to reconfigure the PHP that ships with OSX to meet Drupal's requirements, but wouldn't the smart thing to do be to use MAMP's PHP? You can do this by adding the following line to ~/.profile, adjust as needed.

alias drush='/Applications/MAMP/bin/php/php5.4.10/bin/php /usr/local/drush/drush.php'

For this to take effect you'll need to log out and back in, or run the following command.

source ~/.profile

Parts of these steps may require elevated levels of privilege, so if you get tripped up in certain places be sure to check permissions. Happy drushing!