Kevin Shoesmith

Drush is a command line tool that makes creating, managing and maintaining your Drupal installation and its modules remarkably fast and efficient.

If you don't use the command line in the course of your web development work, spend the time to become familiar with some basic commands. Not only will it save you untold amounts of time and effort, it'll make you feel like a hardcore hacker.

As is often the case, jobs sometimes require installing and developing your Drupal site on a shared environment that you don't have root permissions for. While installing Drush on a server you have full control of is fairly straighforward, installing on a shared environment takes a few more steps.

Let's dive right in and see what's involved.

Prefatory note: If your web host doesn't allow shell access to its shared servers, you're out of luck and should think about using a different host. Yes, really.

Installing Drush

  1. Open a terminal window (or terminal emulator in Windows), log in to your server, and browse to home directory of your account. Type the command:
    ls

    and press Enter to see the contents of the current folder. You'll know you're in the right directory if you see /public_html or /www in the list of files and folders. If not, change to the level above by entering:

    cd ..

    That will take you up one level in the directory structure. Repeat that process typing 'ls' each time, until you see you're in the right directory. 

  2. Look for the /bin directory. This is usually created by default with shared accounts, and contains the commands and utilities that you use to work on the server. When you see /bin listed, change to that directory by typing: 
    cd bin

    If it's not there, create it by typing (at the prompt):

    mkdir bin
  3. Change directories so that you're in the newly created folder, again using the
    cd

    command, and download the tarball of latest version of Drush by typing:

    wget http://ftp.drupal.org/files/projects/drush-All-versions-x.x-xxxx.tar.gz

    The file name of the tarball might be different, but you can find the latest version of the project at http://drupal.org/project/drush.

  4. After the tar file downloads, extract it by entering:
    tar xzvf drush-All-versions-x.x-xxxx.tar.gz

    Then delete the tarball by entering:

    rm drush-All-versions-x.x-xxxx.tar.gz
  5. Change to the /drush/ directory by entering:
    cd drush

    and then enter:

    chmod u+x drush

    This ensures the drush file has the permissions is needs to be run when it's called.

  6. So that we don't have to write out the full path to the Drush executable each time we want to use a Drush command, let's create a path to the Drush executable by making a path link. First, make sure you're still in the Drush folder and then type:
    pwd

    The path to the current directory will be printed for you. Copy the path, which might look something like

    /home/bin/drush/

    and then execute:

    export PATH=$PATH:/home/mysite/bin/drush
  7. Check that Drush has been successfully installed, and your link created by entering:
    drush

    on the command line. If you see a list of all the Drush commands listed on the screen, you're ready to roll with Drush!

Resources

Add new comment