Installation for Linux and Unix (including Mac)

Drush can be installed in Linux or Unix systems, manually or automatically, by a package management system such as PEAR, Aptitude, Port, Homebrew, and others (depending on your distribution). Although the automatic approach offers a quick and easy way to install Drush, there are some disadvantages:

  • Some package management systems do not have Drush 4.5 available yet. For example, Ubuntu 11.04 installs Drush 4.4 through Aptitude.
  • Drush may not be available at the official channels and you may need to add a backports channel in order to discover it. For example, the PEAR installation requires that you first install PEAR and then add the channel where Drush can be found and installed. Moreover, PEAR has to be installed previously and the installation process varies depending if you are using Linux or Mac.
  • Some of them may not install everything in the right place. Aptitude installs Drush in Ubuntu without its documentation, so the drush topic command would not work.

After this reasoning, the most effective method is installing Drush manually, as it ensures that we are installing the correct release. Installing a previous version may result in some commands used in this book being made redundant, or unexpected results from other commands.

Tip

For instructions on how to install Drush on shared hosting systems, read the contents of http://drupal.org/node/1181480.

The installation process

  1. In a web browser, open the Drush 4.5 release page at http://drupal.org/node/1247086.
    The installation process
  2. Download the zip or tar.gz to your home path. You can check where your home path is, with the following command:
    $ echo $HOME
    /home/juampy
    
    
  3. Extract the contents of the compressed file. For drush-7.x-4.5.tar.gz use the following command:
    $ tar -zxvf drush-7.x-4.5.tar.gz
    drush/
    drush/examples/
    drush/examples/example.aliases.drushrc.php
    ...
    
    

    Tip

    Downloading the example code

    You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

    • Alternatively, if you downloaded drush-7.x-4.5.zip, execute the following command to extract its contents:
    $ unzip drush-7.x-4.5.zip
    Archive: drush-7.x-4.5.zip
    creating: drush/
    creating: drush/examples/
    ...
    
    
  4. Change directory to drush.
    $ cd /home/juampy/drush
    
    
  5. Set permissions to the drush executable file in order to be able to run Drush with the following command:
    $ chmod u+x drush
    
    
  6. Now try to execute it by typing its name:
    $ ./drush
    Execute a drush command. Run `drush help [command]` to view command-specific help. Run `drush topic` to read even more documentation.
    
    
    • You should see the Drush help as shown in the previous output.
  7. Create a symbolic link of the Drush executable to any of the directories listed at your PATH environment variable; so you do not have to type /home/juampy/drush/drush every time you use it. Note that this command will ask you for your administrator password in order to proceed:
    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games:/home/juampy/local/bin: /opt/android-sdk-linux_x86/tools
    $ sudo ln -s /home/juampy/drush/drush /usr/local/bin/drush
    
    
  8. Verify the installation by going to another directory and running drush:
$ cd /home/juampy
$ drush

  • You should see an output similar to the one in step 6. Now you can start using Drush in your Drupal projects.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.83.62