Developing and Administering a Drupal website can be tedious with so many module, permission choices and configuration values.
Drush is a command line shell and scripting interface for Drupal. Drush allows you the website developer or administrator to easily download, enable, disable, uninstall, and update modules/themes/profiles/translations using an interactive shell in a familiar Linux package management style. For instance you can `drush dl views` and then `drush en views` in a Drupal webroot to install the Views project. Or, you can update your entire site and its Drupal related dependencies with `drush pm-update`.
Drush can save you countless hours spent in performing administrative and development related tasks on your website. In the remainder of this article I will describe how to properly install Drush for use with your Drupal installations under shared hosting. If your website is a VPS or a dedicated host the recommended way to install Drush is via PHP Pear.
For Shared Hosting
Assure you have shell access to your server. For your Arvixe account simply submit a ticket to request Shell Access to your server.
Login via SSH and change directory to your home directory:
Download and extract the current stable .tar.gz release from the Drush Project Page, as of this writing that is 7.x-5.9.
download Drush files:
Extract the archive using tar:
tar -xvzf drush-7.x-5.9.tar.gz
Since Drush is simply an interactive shell for Drupal and not a Drupal module. It’s now on our system. A single installation of Drush can be used to manage any number of Drupal websites across many servers. In order to facilitate ease of accessing Drush typically a Bash alias is created to point to this single install of Drush.
Open your .bash_profile file found in your home directory and append:
This allows us to cd into any Drupal directory and issue drush commands within the site. Now you can logout and log back into your shell account or simply reload your .bash_profile using:
To test your installation of Drush is complete from any directory try:
# drush --version
You will likely be greeted with this rather unfriendly message:
# drush --version The following restricted PHP modes have non-empty values: [error] magic_quotes_gpc. This configuration is incompatible with drush. Please check your configuration settings in /usr/local/lib/php.ini or in your drush.ini file; see examples/example.drush.ini for details. drush version 5.9
Drush is designed to be secure and not rely on magic configuration PHP values that will soon be removed in PHP 5.4, and currently deprecated in PHP 5.3. To work around this error the cleanest mechanism is to provide a drush.ini file which can locally override the php.ini loaded by PHP when you invoke Drush.
For the curious, you can find what ini file is loaded by php by issuing:
Using your favorite text editor create the following drush.ini file in your extracted drush directory, or if you like to store your Drush tweaks and configuration in a place more friendly for upgrades you can create a directory in your Home folder called .drush and place it there. The files’ contents should be:
# drush.ini magic_quotes_gpc = 0 magic_quotes_runtime = 0 magic_quotes_sybase = 0
Now attempt to run Drush again:
#$ drush --version drush version 5.9 #$
To assure Drush can properly administer your site you can issue the following commands from a Drupal webroot (where you extracted the Drupal sourcecode) for a website you are hosting:
# What is the status of our website and modules. drush status # Clear the Drupal cache tables for our website. drush cc all # View help for Drush core commands and installed 3rd party modules with Drush support. drush help
Additional Drush Resources
If you have any questions or concerns post a comment here or in the Drupal forum for Arvixe.
Additionally Drupal has a large community of contributors feel free to look at the Drupal Community handbook pages for Drushdrush.ws website for additional Drush information.