Installing Drupal with Drush

Drush (Drupal Shell) is a command line tool for Drupal which allows us to perform all sorts of Drupal related tasks using the terminal. For example we could make a backup of all the code, files and database, download/install/uninstall modules or clear the cache to name a few. Being able to perform all these tasks from one place instead of navigating to lots of different locations saves time and provides us with a consistent environment and user experience. Today we are going to use Drush to download and install Drupal with just a few lines of code.

Installing Drush

In this post I will be concentrating on using Drush with OSX. If you are using windows you will find more information here. If you haven’t already done so please download Drush here. Now, extract the archive you’ve just downloaded to /Users/YOURUSERNAME/ so that the path will be /Users/YOURUSERNAME/drush-master. Rename the folder ‘drush-master’ to ‘drush‘.
The next thing to do is tell the system where it can find the Drush program. To do so we will add the location of Drush to the PATH variable. Please open up the file .bash_profile located in /users/YOURUSERNAME/.bash_profile  and add the following line of text:

export PATH=$PATH:/Users/YOURUSERNAME/drush

Now when you fire up the terminal, Drush should be installed. You can check this by typing ‘$ drush help’. If this brings up the Drush documentation all is well.

Installing Drupal

First create a new empty database. I have created one with the name ‘drupalplay‘. In the terminal navigate to the location where you want to store the Drupal folder and tell Drush to download Drupal with the following line of code:

$ drush dl drupal-7.x

This downloads the latest development version of Drupal. If you want the latest recommended release then just type ‘$ drush dl drupal‘. Rename the folder ‘drupal-7.x-dev’ to whatever you want to name your installation. Again, I have chosen the name ‘drupalplay‘. Now in the terminal navigate into the folder drupalplay and begin the installation with the following code:

$ drush site-install minimal --account-name=YOURNAME --account-pass=YOURPASSWORD --db-url=mysql://YOUR_DB_USER:YOUR_DB_PASSWORD@localhost/drupalplay

With this code we have told Drush to perform a Drupal installation with the ‘minimal’ profile, specified an accountname and password and provided a database username, database password and database location. For more options please visit

Thats it. With a few lines of code we’ve downloaded and installed Drupal. And now you have Drupal installed anyway it’s a good time to start exploring the possibilities of Drush!