Installing Drush on MAMP

Drush logo

Laatste update van dit artikel: 14 februari 2015.

Drush geeft command-line toegang tot de Drupal installatie. Ik ben geen grote fan van de command-line maar in het geval van Drush maak ik een uitzondering. De tijd die het kost om Drush op te zetten verdien je gemakkelijk terug tijdens het ontwikkelen. Voorbeelden? Drush pm-update (drush up) bijvoorbeeld update alle core en contrib modules en doet de database updates. Met FTP-toegang doe je daar al snel 10 keer langer over.

Reeds tijdens het ontwikkelen op een lokale omgeving (een AMP-stack, Apache, MySQL, PHP), komt Drush handig van pas.

Ikzelf gebruik MAMP in combinatie met Mac OS X Yosemite.

De PHP versie van MAMP gebruiken

Vooraleer te beginnen, moeten we kijken welke PHP-versie MAMP gebruikt. Open daarvoor MAMP, klik op Preferences en dan PHP. In mijn geval wordt PHP versie 5.6.2 gebruikt.

MAMP php versie

Wanneer we werken met MAMP, dan willen we de PHP van MAMP gebruiken, niet de systeemversie. Open de Terminal en geef een commando in om te kijken welke php versie gebruikt wordt:

which php

Normaal krijg je hier als antwoord /usr/bin/php. Wij willen echter de versie gebruiken onder /Applications/MAMP/bin/php/php5.6.2/bin/php. De verwijzing naar de MAMP versie van PHP doen we door het profiel te wijzigen met root (sudo) toegang. Typ:

sudo nano ~/.bash_profile

en voeg vervolgens volgende regel toe:

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

Klik vervolgens CTRL + X en dan Y en Enter. Herlaad nu het profielbestand:

source ~/.bash_profile

...en bekijk de PHP-versie met het commando dat we daarnet ook gebruikten:

which php

Composer installeren

Ok. Nu kunnen we beroep doen op de algemene documentatie van het Drush project, zoals ook teruggevonden op Github. De gemakkelijkste manier om Drush te installeren is door middel van Composer.

Browse naar de home map met terminal:

cd ~

Download Composer:

curl -sS | php

Composer install

Maak een usr/local/bin map:

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

En verplaats, vanaf de home map, composer.phar naar de nieuw gecreëerde /usr/local/bin map:

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

Vervolgens moeten we Composer in het PATH plaatsen, zodat we het globaal kunnen benaderen:

sudo nano ~/.bash_profile

En voeg de volgende lijn toe:

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

Klik vervolgens CTRL + X, Y en Enter.

En herlaad bash_profile:

source ~/.bash_profile

Test tenslotte dat alles goed werkt met het Composer commando:


Install Drush

Vervolgens kunnen we Drush installeren met één commando:

composer global require drush/drush:dev-master

Test vervolgens dat Drush werkt met volgend commando:

drush status

Drush status

Het MAMP shell pad toevoegen

Tenslotte moeten we het MAMP shell toevoegen aan OS X. We moeten dit doen om de MySQL versie van MAMP te gebruiken. Zonder deze stap kunnen we Drush gebruiken om een module te downloaden maar als we een module willen aanzetten (en deze naar de database wil schrijven), dan ontvangen we een hoop foutmeldingen.

Controleer eerst het MySQL pad, normaal is dit /Applications/MAMP/Library/bin. Voeg vervolgens deze lijn toe aan bash_profile, op dezelfde manier als daarnet:

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

De uiteindelijke .bash_profile moet er zo uitzien:

bash_profile for Drush

Voila, Drush werkt nu op de lokale machine en heeft de juiste permissies om alle commando's te kunnen uitvoeren!

Let op! Vooraleer alle commentaren te lezen en in de war te geraken: dit artikel is al twee keer herschreven. De eerste versie had een installatie met Pear, de tweede een manuele installatie en deze versie (dd. 14 februari 2015) heeft een installatie met Composer. De installatie met Composer is veruit de gemakkelijkste methode.



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.


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.


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?


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.


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.


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?


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 :)

In reply to by Thomas Andersen


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.


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.


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 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


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?


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


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.


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


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


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


Best tutorial I found to install both composer and drush successfully for MAMP from this newbie. Thank you.

Add new comment

Plain text

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