Setting Drush up
What you will need to make Drush work
For starters, you will want to make sure you have a local Apache MySQL (or Postgres) and PHP stack installed.
You will need to make sure that you have the PHP command line interface (php-cli) installed. You can check this by querying for the php version:
0 nat@pigtown:~$ php -v
PHP 5.2.6-1+lenny4 with Suhosin-Patch 0.9.6.2 (cli) (built: Nov 22 2009 01:50:58)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend TechnologiesIf you do not have this, and are running Debian or Ubuntu you can install it with: "aptitude install php5-cli".
Getting Drush
To get the source tar ball from drupal.org go here:
http://drupal.org/project/drush
If you are using Debian Squeeze (testing) or Sid, you can install the package with apt-get/aptitude/Synaptic. The package name is "drush" Details:
http://packages.debian.org/squeeze/drush
There is a package making its way into Ubuntu. Its currently in the Lucid Lynx
https://launchpad.net/ubuntu/+source/drush
Note: Both Debian and Ubuntu releases are Drush 2.0-6 but Drush has moved to 2.1.x so these packages are a little old at this point. Given the current rapid development pace in Drush, and provided that you are on the Drupal security list, I would recommend just tracking the package.
Installing the Drush package
There is lots of good install information in Drush's
It is important to remember that Drush runs outside of Drupal. One instance of Drush can be used to manage every Drupal site on your machine.
There are a number of different ways to install Drush, how you do it depends on your operating system, preferences and situation. For instance, if you are on a shared hosting account, you may be limited in where you can put the Drush package.
For these examples use the package from drupal.org. From you home directory, grab and decompress a copy of Drush (2.1):
$ wget http://ftp.drupal.org/files/projects/drush-All-Versions-2.1.tar.gz && tar -zxvf drush-All-Versions-2.1.tar.gzSystemwide Installation
If you are installing Drush to work systemwide you will need to make it available to all users so that it is in their PATH. The "right" place to put external libraries in a *nix system varies by OS and by preference. In Debian based Linux ditros (like Ubuntu) custom libraries can be placed in /usr/local/lib/ (tagent: .deb using package managers by default use /usr/lib for such things, using /usr/local/lib keeps your custom Drush, as well as other custom things you add cleanly outside of the apt system.).
Say we are moving Drush to /usr/local/lib, run something like:
$ sudo mv drush /usr/local/lib/You will then need to create a symbolic link so that drush appears as a normal command.
$ ln -s /usr/local/lib/drush/drush /usr/local/bin/drushThis should make drush available to all users. If you are having permissions problems, make sure that Drush is executable.
$ chmod u+x /usr/local/lib/drush/drushYou may also need to do the same for the sym link.
Individual User Installation
Installing Drush for an individual user is probably easier than doing it system wide. For this example we are just going to leave Drush in the user's home directory. Again, the readme file covers multiple ways of doing this. I will just use aliases. Create an alias (assuming drush is in your home directory):
$ alias drush='drush/drush'You may need to log out and back in for this alias, or just open a new terminal tab or window.
Using Drush
Once installed and setup, you can use drush while in any Drupal directory. At any time you can get a synopsis of drush usage by issuing the help command:
$ drush helpYou can also get help on specific drush functions by specifying the function eg:
$ drush help dlWorking with modules in Drush
Fun things that you can do with Drush
Here's some extra one liners that you can use with Drush. Remember that you must be somewhere in the directory tree of a Drupal install so that Drush knows which site its working on.
This one liner will dump the database of a Drupal site, and place a compressed file inside your home directory. The compressed dump file will have a datestamp in the file name, eg: drupal_site_2009-12-03T11_56_22-0500.mysql.gz. Change the "drupal_site" part (or any other part of the filename), to make it more readable for yourself.
$ drush sql dump | gzip > ~/drupal_site_date +%FT%H_%M_%S%z.mysql.gzUsing the example dump we just created, we can use Drush and gunzip to get a compressed database dump file into a Drupal site in one line as well:
$ gunzip < ~/drupal_site_2009-12-03T11_56_22-0500.mysql.gz | drush sql cliscor has a script he demoed at the last boston camp which simply dumps the code with drush instead of dbscripts, this is the lightest-weight way to start getting your code and database committed together: