Web Courses Academy Blog

From 0 to Drupal with Drush on MacOSX 10.6+

Author: Carl Heaton
He is our senior instructor and originally from Manchester UK. Carl teaches our Web Design and Online Marketing Courses.
drupal-with-drush
Quick jump to topics
Sharing is caring

Drush is a powerful scripting interface and shell for Drupal that lets you manage your Drupal systems quickly and easily from the command line. With just a few commands you can:

Drupal Courses Bangkok

Drush is a powerful scripting interface and shell for Drupal that lets you manage your Drupal systems quickly and easily from the command line. With just a few commands you can:

  • Install and configure a brand new Drupal site
  • Enable and disable modules
  • Download and install new modules and plugins
  • Test your Drupal site
  • Backup, update and migrate your databases
  • Control many supported modules
  • And much much more…

Just thinking about all the clicking and waiting required to accomplish some of these tasks gives both my mouse hand a cramp and my head an ache.

This guide assumes that you have some familiarity with Unix and some Drupal experience, if not have no fear Web Courses Bangkok now offers both Drupal and Unix training online, and on location.

  1. Download and install MAMP, it bundles Apache, MySQL and PHP
  2. Fire up your trusty terminal, or the my personal favorite iTerm2

    MAMP puts it’s webroot here: /Applications/MAMP/htdocs
    We’re going to create a symbolic link for convenience, to save some typing

     $ cd ~
     $ ln -s /Applications/MAMP/htocs htdocs
    

    Since we’re going to be using the Apache and Mysql commands that come with MAMP instead of installing our own, we need to add MAMPs binaries to our PATH. Edit your shell’s init script (.profile, .bashrc, .zshrc). I’m running zsh, so I added the following to the end of my .zshrc file:

     export PATH=$PATH:/Applications/MAMP/Library/bin
    
  3. Install the powerful package management system Homebrew by running the following command:
     $ /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
    
  4. Install wget (web get) with Homebrew, this let’s you download stuff from the web directly to your shell directory
     $ brew install wget
    
  5. Download PEAR, PHP’s package management system
     $ wget http://pear.php.net/go-pear.phar
     $ php -d detect_unicode=0 go-pear.phar
    
  6. Make sure PEAR works, it should display a list of sub commands
     $ pear
    
  7. If this doesn’t work make sure to add ‘Users/ACCOUNT/pear/bin’ to your shells PATH (as we did in step 2). I’m still running ZSH so I added the following to our recently added export line:
     export PATH=$PATH:/Applications/MAMP/Library/bin:/Users/ACCOUNT/pear/bin
    

    Don’t forget to replace ACCOUNT with your user account. Close and reopen your terminal if needed.

  8. Install Drush with the following PEAR command
     $ pear channel-discover pear.drush.org
     $ pear install drush/drush
    
  9. Apply the following fix for the latest MAMP 2.0 found here

    Create the missing directory:

     $ sudo mkdir -p /Applications/MAMP/bin/php5/bin
    

    Symlink to the proper binary

     $ sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /Applications/MAMP bin/php5/bin/php
    

    Make sure you can execute it

     $ sudo chmod a+x /Applications/MAMP/bin/php5/bin/php
    
  10. Enter your htdocs folder and create a Drupal 7 website using Drush!
    $ cd ~/htdocs
    $ drush dl drupal
    $ drush site-install standard --account-name=admin --account-pass=admin --dburl=mysql://root:root@localhost/YourMySQLDatabase
    
  11. Visit you new Drupal website here http://localhost:8888/drupal-7.X
    Replace the X with the version of drupal you installed with Drush.
  12. Rejoice, you can now use drush!

Drupal Courses in Bangkok

To learn more and take your Drupal knowledge to the next level check out our Drupal and Unix training available both online, and on location.

More great articles
There is more where this came from
Join our monthly newsletter packed with course dates, latest articles, free resources and job opportunities

Sorry. You must be logged in to view this form.

Promise to only send you useful interesting newsletters once a month.