Installing Drush on MAMP

November 5, 2013
Drush logo

Last article update: March 9, 2017
(tested on new MacOS Sierra install, without a problem)

Drush provides command-line access to the Drupal installation. I'm not a big fan of the command-line but in the case of Drush I make an exeption. The time it takes to set up Drush is nothing compared to the time you gain during development. Examples? Drush pm-update (drush up) updates all core and contrib modules, including the database updates. With FTP-access this takes much longer.

Right from the start, during the development on a local machine (an AMP-stack, Apache, MySQL, PHP) Drush comes in handy.

I use MAMP on Mac OS X Yosemite.

Use the PHP version of MAMP

Before starting, we need to see what PHP version MAMP uses. To see that, open MAMP, click on Preferences and then PHP. In my case, PHP version 5.6.2 is used.

MAMP php versie

When we work with MAMP, we want to use the php version of MAMP, not the system version. Therefore, first check the PHP version in use by typing this command into Terminal:

which php

Normally you will receive the output /usr/bin/php. We want to use the version under /Applications/MAMP/bin/php/php5.6.2/bin/php. To change this, we have to edit the profile with root (sudo) access. Type:

sudo nano ~/.bash_profile

Now add the following line:

export PATH=/Applications/MAMP/bin/php/php5.6.2/bin:$PATH

Then click CTRL + X, then Y and Enter. In order to see the changes we have to reload the file with the profile we just changed:

source ~/.bash_profile

... to check the PHP version with the same command we used in the beginning of this tutorial:

which php

Install Composer

Ok. From here on, we can use the documentation of the Drush project, as found on Github. The easiest way to install Drush is by using Composer.

In the terminal, browse to your home directory:

cd ~

Download Composer:

curl -sS | php

Composer install

Create a usr/local/bin directory:

sudo mkdir -p -m 755 /usr/local/bin

And from within the home directory, move the composer.phar to the newly created /usr/local/bin folder:

sudo mv composer.phar /usr/local/bin/composer

Next, we have to put Composer in our PATH, so we can access it globally. Run:

sudo nano ~/.bash_profile

And add the following line:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Then click CTRL + X, then Y and Return (Enter).

In order to see the changes we have to reload the file with the profile we just changed:

source ~/.bash_profile

To test if everything is working well, just run the Composer command:


Install Drush

Next, we can install Drush with one command:

composer global require drush/drush:dev-master

This will install the most current version. If you want to install another version, you can change this with the same command. For example, if you need Drush version 8 with support for Drupal 6, 7 and 8, use this command:

composer global require drush/drush:8.*

Test by using the next command:

drush status

Drush status

Add the MAMP shell path

Lastly ,we have to add the shell path to OS X. We need this to use the MySQL version of MAMP. Without this step we can use Drush to download a module but when we want to enable a module, we will receive a bunch of errors.

First, check the MySQL path, normally this is /Applications/MAMP/Library/bin. Then add this line to .bash_profile, in the same manner as the other two lines:

export PATH=/Applications/MAMP/Library/bin/:$PATH

The final .bash_profile should look like this:

bash_profile for Drush

Voila, Drush is functional on the localhost and has the right permissions to run all the commands!

When you run into problems, like "PDOException: SQLSTATE" or "Command pm-enable needs a higher bootstrap level to run", check these things:

  • Make sure Apache and MySQL are running (check this setting in the MAMP interface)
  • When running Drush, make sure you use the command 'cd' to navigate to the local folder of the website
  • When you update MAMP, the php version can change. For best result, the php version of MAMP and the path in the .bash_profile should match
  • Try '' instead of 'localhost' and define the correct port (check the MAMP port, mine is '8889') in the settings.php file; try both options (debug MySQL issues with drush status -d)
  • When it's a very big installation, check the memory limits in the MAMP configuration files

Note, before reading the comments and getting confused: this article has already been revised two times. The first version featured an installation of Drush with Pear, the third a manual install and this version (14th of February 2015) has an install with Composer. The installation with Composer is by far the easiest.


I get the erro
-bash: /Applications/MAMP/bin/php/php5.4.10/bin/php: No such file or directory
someshow it didnt see the php defined version

In my case it's similar to Luiz. It doesn't see that I'm using 5.5.3
$ which php

$ drush
Failed loading /Applications/MAMP/bin/php/php5.3.20/lib/php/extensions/no-debug-non-zts-20090626/ dlopen(/Applications/MAMP/bin/php/php5.3.20/lib/php/extensions/no-debug-non-zts-20090626/, 9): image not found

@Luiz: I fixed this by creating a symbolic link
$ ln -s /Applications/MAMP/bin/php/php5.4.19/ /Applications/MAMP/bin/php/php5.3.20

but now: /usr/bin/drush: line 129: /Applications/MAMP/bin/php/php5.4.19/bin/: is a directory
/usr/bin/drush: line 129: exec: /Applications/MAMP/bin/php/php5.4.19/bin/: cannot execute: Undefined error: 0
Can someone help?

Thanks for the input! I had some issues myself when using Pear in combination with Drush for Omega 4. Omega 4 needed the 7.0-dev version of Drush, which wasn't an option in combination with Pear. Therefore I did a manual install of Drush recently. I changed the tutorial accordingly by removing the Pear commands.

Thank you, thank you, thank you. I've been fighting with this for a day.

Simple, detailed steps and it works

I spent the last 2 hours reading dozens on forum topics and stackoverflow questions


Read the "" that comes along with drush, and all this information is in there too. Very helpful post. Thanks!

Thanks for this post! Drush now requires Composer for install, so I ran into issues using the manual method. The is not 100% clear about how to proceed, so here's what I did.

First install Composer:

sudo curl -sS | php
sudo mv composer.phar /usr/local/bin/composer 

Next, install Drush:

composer global require drush/drush:6.*

Then follow the instructions here:

Don't forget to reload your bash_profile.

Thanks for this tip. I've been pulling my hair out trying to get this to work for several hours now and your comment just saved me!

How can it connect to the database? It needs the socket right?

There doesn't seem to be any directory: /usr/local/bin in a fresh install of OS X Mavericks.
I have usr/bin
Is this the same thing?

I created that directory.

Installed Drush from git (used the master branch to get the latest version).

Drush is available on my $PATH, when I type in "drush" from any terminal window, I get the help page (which I would expect).


I have MAMP installed running php5.4.4, with apache running on port 80, and have a drupal installation that is running in MAMP, and can be seen from a browser window at "http://drupalxp.local".

Opening a terminal window and navigating to the root drupal installation directory and running any drush command that requires bootstrapping the site results in the following error from Drush:

"No Drupal site found, only 'drush' cache was cleared."

Any ideas? I've googled all over the place searching for a solution to this one.

Finally, I have a solution:

Edit the settings.php file of your drupal installation, and go to the database settings entry.

change the host line to:

'host' => php_sapi_name() == 'cli' ? '' : 'localhost',

Solution courtesy of this post on


This week I saw someone following the tutorial, getting stuck with the message about Composer not being installed.

I don't feel like experimenting right now ("if it ain't broken, don't fix it") but I will change the tutorial when I have the opportunity.

Just want to add my thanks for this. Clear, concise and it works.

I get:
macpro:~ user$ drush
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see

So what to do?

Rob, in the drush folder run:
composer update

I finally managed to update the article to an installation with Composer.

I've tested this method with my desktop and laptop and it is working well.

Hi :)

Thank you so much for your guide. But.. I just made a new installation of OS X Yosemite, and the first thing I tried to install after mamp was drush.

When I install composer I get some "permission denied" - " could not be fully loaded, package information was loaded from the local cache and may be out of date" - anyone having the same problem?

When I try to "drush cc all" I get the warning: "No Drupal site found, only 'drush' cache was cleared. ". I have been trying to solve the problem for 3 weeks now, and i still haven't found any solution. Help is so much appreciated :)

Make sure (1) Apache and MySQL (via MAMP) are up and running and (2) check that you are running Drush within the Drupal site folder. 

Apache and MySQL (via MAMP) are up and running. Inside the Drupal site folder I run: drush status. I get:
Drupal version : 7.36
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database port :
Database username : root
Database name : omegadoen
PHP executable : /Applications/MAMP/bin/php/php5.6.6/bin/php
PHP configuration : /Applications/MAMP/bin/php/php5.6.6/conf/php.ini
PHP OS : Darwin
Drush version : 7.0-dev
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /Volumes/Doxy/htdocs/omegadoen
Site path : sites/default

Then I run: drush omega-wizard. I get:
The drush command 'omega-wizard' could not be found. Run `drush cache-clear drush` to clear the commandfile cache if you have
installed new extensions.
Drush was not able to start (bootstrap) the Drupal database.
Hint: This may occur when Drush is trying to:
* bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
* connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See for details.

Clearing the cache does not solve the problem. The site has been installed and is working. I haven't a clue what to do next. Help is appreciated.

Try 'drush cc drush', as stated.

Try adding the port number (usually 8889) and '' instead of localhost in settings.php.

Just got a brand new computer - macbook pro with 10.10.2 (Yosemite).
I installed MAMP and got a local Drupal development site going.
I found this tutorial and went faithfully through it.
There appeared to be a hiccup with the 'composer global require drush/drush:dev-master' step.
OSX showed a popup saying the git command required Xtools.
I closed the Terminal window and installed it.
I fired up Terminal and ran the ' composer global require drush/drush:dev-master' again.
It did its thing successfully.
I completed the rest of the steps.
Now I have Drush fully functional on my local machine.
Thank you very much.

Would you mind providing the steps you took to get drush working properly? I followed the steps in the article but keep getting the error, "No Drupal site found, only 'drush' cache was cleared."


Very good tutorial. Thanks Bram!

Thank you for your nice tutorial. and please add this paragraph to it:

Make sure that the mysql port in the MAMP is set to default mysql port (3306)
check it on the MAMP preferences section.

unless Drush will not work.

Thank you for this tutorial! I have spent hours trying to get it to work. This worked the first time!

Thank you for this tutorial!

I could install drush on Yosemite 10.10

and when I type drush status his works "
PHP executable : /usr/bin/php
PHP configuration :
PHP OS : Darwin
Drush script : /Users/jeff/.composer/vendor/drush/drush/drush.php
Drush version : 8.0-dev
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
But when I run the command "drush dl ...."
I have the following message
simplexml_load_file(): I/O warning : failed to load external entity [warning] "" Project.php:72
Failed to get available update data from [error]
Could not download requested project(s). [error]
Do you know how to fix this problem?

thank you

A really, really, REALLY useful post. Thank you for sharing. Saved me some time and frustration.

I followed all the directions.
Command: drush status
drush dl omega
Inside the project folder omega, command: drush omega-wizard
Does not work
I get:
The drush command 'omega-wizard' could not be found. Run `drush [error]
cache-clear drush` to clear the commandfile cache if you have
installed new extensions.
Drush was not able to start (bootstrap) the Drupal database. [error]

(By the way: on Debian Jessie I don't have this problem).

What to do?

Follow these steps:
Terminal: sudo nano ~/.bash_profile
Add the following line (including the word export): export DRUSH_PHP="/Applications/MAMP/bin/php/php5.6.10/bin/php"
(adjust php5.6.10 to your version)
Afterwards run:
source ~/.bash_profile

That did it for me. Good luck!

Thanks for the great tutorial. I got it working. But I did get this error:

file_put_contents(/Users/rebecca/.composer/vendor/composer/autoload_namespaces.php): failed to open stream: Permission denied after putting in the command "composer global require drush/drush:dev-master". What do you think this means and will it cause problems?

I figured it out. you have to run composer global require drush/drush:dev-master with the sudo command. Doing that eliminated all the errors I was getting.

THANK YOU!!!! Err Merr Gerrd this was driving me mad! Then you solved it for me!

Many thanks for the clear and concise instructions. Worked like a charm. Keep up the great work.

You Rock!!!! I have spent about 4 hours trying to get Drush v8 to work on MAMP, thank you!!!!!

Just wanted to say that i successfully installed Drush on my fresh OSX El Capitan in 5 minutes using your tutorial.

Thank you!!!
work like a charm !

Thank you
Drush was having trouble installing, editing and pretty much executing any command apart from downloading drupal and modules.
I read several blog posts about this, it never worked and i eventually gave up.

Today i woke up and decided drush Must be fixed !
Your blog post helped A LOT !

Thank you man

your tutorial is simply perfect !

Just did every thing step by step with absolutely no errors nor warning

I just adapted the path of my php to the php version used by mamp 3.5.

You saved my day!

Thank you so much :) Article is so clear and helpful; and the troubleshooting bullet points saved me tons of time...

Nice Tutorial!... Works swimmingly... The only thing is that I've installed Drush as follow:
# composer global require drush/drush
instead of
# composer global require drush/drush:dev-master
because I got an error:

Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for drush/drush dev-master -> satisfiable by drush/drush[dev-master].
- drush/drush dev-master requires codegyre/robo ~1.0.0-beta1 -> satisfiable by codegyre/robo[1.0.0-beta1] but these conflict with your requirements or minimum-stability.
Installation failed, deleting ./composer.json.

Thanks again!

A. Diaz

Lukte me ook niet meteen, maar was opgelost met deze drie commands in Terminal:

cd /usr/local/bin
sudo ln -s /Applications/MAMP/Library/bin/mysql
sudo ln -s /Applications/MAMP/Library/bin/mysqldump


Bram, just upgraded to El Capitan and re-installed Drush with your tutorial. Nordicmaterial says Thank You!

This tutorial is just what I was looking for! Thanks a lot!

Thanks for the post. It almost worked :)
I get this on Yosemite, with Drupal 8
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for drush/drush dev-master -> satisfiable by drush/drush[dev-master].
- drush/drush dev-master requires consolidation/robo dev-master -> satisfiable by consolidation/robo[dev-master] but these conflict with your requirements or minimum-stability.

Installation failed, reverting ./composer.json to its original content.
MacBook-Pro:~ erwino$ drush status
PHP executable : /Applications/MAMP/bin/php/php7.0.10/bin//php
PHP configuration : /Applications/MAMP/bin/php/php7.0.10/conf/php.ini
PHP OS : Darwin
Drush script : /Users/erwino/.composer/vendor/drush/drush/drush.php
Drush version : 8.1.3
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Does anybody see what the problem is

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.