#Installing Drush on MAMP
##Use PHP version of MAMP
XCode also installs a version of php on the command line. We want to use the mamp version of php. First check which version is running on your mamp installation. ( mamp panel -> preferences -> PHP ). In my case this is php5.6.10.
Launch the terminal app and type
which php
You will receive something like /usr/bin/php. This is the XCode version. We don't want that, so let's point the terminal to the mamp version. We can do this with :
sudo nano ~/.bash_profile
And add the following line:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
If you have a different version of php in mamp, update the path to your version number. To write the file and exit nano type CTRL (not the mac key ) + X and then type Y.
We have to reload .bash_profile, otherwise terminal will keep on working with the old configuration. You can do this with
source ~/.bash_profile
or if you are lazy, just quit the terminal and restart it. Now you can check the php version again:
which php
and you should see the mamp php version. If not retrace your steps.
##Install composer
Drush needs composer, so let's install it.First we download composer. Open up the terminal and type:
cd ~
curl -sS https://getcomposer.org/installer | php
Check if you have the following directory structure. You can do this with
ls /usr/local/bin
If an error shows up follow this step. Otherwise skip it.
sudo mkdir -p -m 755 /usr/local/bin
Now we are going to move composer to /usr/local/bin
sudo mv composer.phar /usr/local/bin/composer
Now we need to tell terminal where composer lives
sudo nano ~/.bash_profile
and add the following line
export PATH="$HOME/.composer/vendor/bin:$PATH"
CTRL + X and type Y again. Reload the bash_profile settings
source ~/.bash_profile
Now check if composer is running with typing in the terminal
composer
You should see an overview of composer commands. If not retrace your steps.
###Install drush
Now install drush by typing:
composer global require drush/drush:dev-master
Test drush by typing
drush status
###Add mamp shell path
Now we need to to one more thing. We need to tell terminal to use MySQL version of mamp. If we don't do this drush can download a module, but can not enable it.
Navigate with the finder in your /Application/Mamp folder and search for the mysql path. Normally it is /Applications/MAMP/Library/bin
Now open up terminal and type
sudo nano ~/.bash_profile
Add following line. If your mysql in mamp is on another path, update the path
export PATH=/Applications/MAMP/Library/bin/:$PATH
Now type CTRL + X and type Y one more time. Reload .bash_profile
source ~/.bash_profile
Voila, now you can use drush with your mamp installation.
###Trouble shooting
If you see this error:
Command pm-enable needs a higher bootstrap level to run
Check this things:
- Make sure that mamp with mysql and php is running
- You pointed the terminal to a drupal folder in your htdocs folder of mamp
- If you updated mamp, the php version can change. If this is the case update the paths in bash_profile
Hi, thank for this complete explanation. It is really easy to follow. I have forked your gist : https://gist.github.com/SebastienGicquel/35e7940d77623d0763f2a412464456fa
I follow this answer on stackoverflow which explains how you can make your path update automatically by adding an extra line to your .bash_profile
Maybe you can update your gist if you found this solution useful