Book Image

Drush User's Guide

By : Juan Pablo Novillo Requena
Book Image

Drush User's Guide

By: Juan Pablo Novillo Requena

Overview of this book

<p>Drush is a command line interface for Drupal. Most of the tasks for building and maintaining a website are repetitive and involve filling in forms on administration pages. The majority of these tasks can be achieved with a single Drush command, shortening the development and maintenance time of a project drastically.</p> <p><em>Drush User's Guide</em> will allow you to be more productive and efficient in building and maintaining your Drupal sites through the command line. You will learn to install Drush on different platforms, and manage and configure your Drupal site by learning how to use and create Drush commands.</p> <p>Become a Drush expert by exploring its command toolkit; customizing it to suit your needs, and extending it with contributed modules.</p> <p>The command line will allow you to download, enable and upgrade Drupal projects in seconds. Back up your files, code and data in one single file, clear the cache, interact with databases, and deploy sites to remote machines - all using simply the command line. Use Drush with your own commands or alter existing ones; and extend the toolkit with a long list of contributed modules.</p> <p><em>Drush User's Guide</em> has everything you need to extend your use of the command line to easily build and manage your Drupal sites.</p>
Table of Contents (10 chapters)

Installation requirements


Drush can be installed manually or automatically, depending on your operating system and preferences. These are explained in this chapter through step by step instructions. You should evaluate them and, whichever you follow, make sure that you end up with Drush 4.5 or higher installed on your system.

Drush is designed for working on Unix-based systems such as Linux and Mac OS X. However, a lot of effort has been put into making some of its commands available in Windows systems.

Note

Windows users can install Ubuntu within VirtualBox to use Drush within a Unix-based environment. See http://www.ubuntu.com and https://www.virtualbox.org for more details.

Linux and Mac users need to verify that they can run PHP on the command line and its version is 5.2 or higher. If you are using Windows, you can jump to the next section as the Drush installer configures PHP automatically for your terminal. The easiest way to check whether you have PHP-CLI installed and configured, is by opening a terminal and executing the following command:

$ php -v
PHP 5.3.5-1ubuntu7.4 with Suhosin-Patch (cli) (built: Dec 13 2011 18:25:14)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

If you got an output similar as the previous one, you can jump to the next section. If not, here are some tips to get PHP-CLI installed on your system.

Installing php-cli on Debian and Ubuntu

Debian and Ubuntu users can easily install php-cli with the following command:

$ sudo apt-get install php5-cli

Once the installation completes, verify the installed version with php -v.

Installing php-cli on Mac

Mac users have php-cli installed by default but need to make it available from anywhere in the terminal. The whereis command helps to find where a command is located. The following command shows how the whereis command is used to find where a command is located, if we have the PHP binary in our system:

$ whereis -b php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz

If the command has found any results, as in the previous example, try executing them appending -v to see if the version is 5.2 or higher. If you have found it, create a symbolic link that points to any of the paths listed within your PATH environment variable. Now, in the future you can just type php instead of the full path where it's located. We will first print the available paths and then create a symbolic link to one of them:

$ 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 /path/to/php/executable /usr/local/bin/php

After that, you should be able to run php -v without errors.

Note

You can find further information about requirements at the Drush README.txt (http://drupalcode.org/project/drush.git/blob/HEAD:/README.txt).