Sunday, January 8, 2012

Install and use Drush for Drupal

Drush (DRUpal SHell) is a command-line shell and scripting interface for Drupal designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.
This instruction should work for Debian, Ubuntu, CentOS:

Install Drush


sudo wget --quiet -O - http://ftp.drupal.org/files/projects/drush-All-Versions-HEAD.tar.gz | tar -zxf - -C /usr/local/share


sudo ln -s /usr/local/share/drush/drush /usr/local/bin/drush


sudo drush



Use Drush
  1. Change into your Web server's root directory (cd /var/www).
  2. Run drush dl drupal-7.0. This downloads Drupal 7.0 from drupal.org and extracts the files into /var/www/drupal-7.0.
  3. Change into the newly created directory (cd /var/www/drupal-7.0) and run thesite-install command:
    drush site-install --db-url=mysql://root:secret@localhost/drupal
    
Answer “y” to the following prompt, and in a few short moments, you'll have a working Drupal install (using the “drupal” database on localhost). To verify, you can browse to http://localhost/drupal-7.0/ and log in using admin/admin as the user name/password, respectively. The site-install command has several additional options; run drush help site-install for full details.

For those of you who work on several Drupal sites across various versions and installations, Drush provides an “alias” mechanism to define the common parameters. To create an alias for this example site here, you can create a file ~/.drush/aliases.drushrc.php containing the following PHP code:
$aliases['example'] = array(
  'root' => '/var/www/example/drupal',
  'uri' => 'example.com',
);


Now you can run drush commands for your example site from any directory usingdrush @example  (for example, drush @example status). To make things even better, aliases can reference remote sites (accessible via SSH) by including the remote-host and remote-user options. See the example.aliases.drushrc.php file from the examples folder in your Drush install directory for full details.




No comments:

Post a Comment