A Rush to Drush

A colleague of mine recently discovered the numerous benefits of using Drush to manage Drupal implementations, and when I mentioned that the drush commands, when entered from the applicable site folder, work just as well with a multisite installation, he was anxious to rock and roll.

That point is often where the line in the sand forms. On one side is the interest in using it&emdash;after all, with one command you can update your core and modules, push a database, etc.&emdash;on the other side of the line is installing a Linux utility outside the comfort of the Drupal admin panel. Prepare to jump over the line!

These instructions are for those installing Drush in a Linux environment. I will make another post and link to it with instructions for installing in a Windows environment.

  1. You will need command-line access to your Linux environment along with root or su privileges. I don't believe that this can be done with only control panel access. If someone discovers that it can, please give me the details. The commands below may have to be preceded with sudo if you do not have root privileges.
  2. Navigate to http://drupal.org/project/drush and scroll down to the Downloads section. Note the version that appears in green in the Recommended releases section. Even though it is marked as 7-x-#.# it is valid for all releases of Drupal from 4 upward. Copy the link address for the tar.gz version, which is currently http://ftp.drupal.org/files/projects/drush-7.x-4.4.tar.gz.
  3. Select a directory outside of your webroot in which to install Drush. For the purposes of this example we'll use /home and refer to it as drush_parent.
  4. cd /drush_parent and change to that directory.
  5. wget http://ftp.drupal.org/files/projects/drush-7.x-4.4.tar.gz The URL is the one we copied earlier. This will copy the file to your current directory.
  6. ls drush* to get the filename to use below.
  7. tar -zxf drush-7.x-4.4.tar.gz This decompresses the archive file and creates a drush folder.
  8. chmod u+x drush/drush Give execution permissions to the drush command.
  9. chmod a+w drush/includes Make the includes folder writable.
  10. ln -s /drush_parent/drush/drush /usr/bin/drush Create a symbolic (soft) link so that the file can be found when you enter the drush command.

That should be all you need to do. Enter the drush command and you should receive a list of commands! Remember that usually you will want to enter drush commands from the site directory of the implementation you want to work with, otherwise drush will complain because it doesn't know which settings file to use. Also keep in mind that if you are running multisite with several sites and you are doing an update, for example, you will need to issue the applicable drush command for each site from within their respective site folder in order to update each database.