Part One: The Can Opener
If MacGyver were a Drupal developer, Drush would be his Swiss Army Knife.
For the record, "Drush" is a mash-up of the "Dru" from Drupal and "sh" from shell. Functionally, Drush marries Drupal to the world of the command line. Even if you are not a command line junkie, you will find Drush very easy to use; in fact, you'll wonder how you ever managed without it.
Drush itself isn't a module; it is installed on your server independently of any Drupal site. Though it's designed for a *nix flavor OS, it can still be installed on Windows — although some functionality will be missing. (To use Drush on Windows, follow these instructions: http://www.drush.org/drush_windows_installer.)
For the rest of us, there are a couple of installation methods available, but my personal favorite is Pear. I like using Pear to install and update Drush because, like Drush, it takes a lot of the labor out of the task of maintaining it. Assuming you already have Pear installed on your server, here's what to do:
pear install drush/drush
Drush will also need Console Table to run. If you need it, just run the command below to install it.
To check to see if Drush installed, try the following:
This should return something like this:
If you don't have Pear available or are on a shared host, you will want to refer to the readme.txt file1 for other install methods.
Now that we have Drush installed we can start the fun. Let's assume you want to install a new site. Change directory to your web root or where you'd like the site to live on the server. Issue the following command:
In the above command, you asked Drush to download the latest version of Drupal via the command "pm-download". If you're anything like me, you're thinking, "That's too much typing." But don't worry, there's an alias: Next time, instead of typing "pm-download" just type "dl" instead.
Drush has now placed the current version of Drupal in a directory relative to your location. So, if the current version of Drupal is 7.18, then the directory will be named "drupal-7.18". Rename the directory or move its contents to the desired location.
Now, change directory to the Drupal root, the same directory that contains install.php. I'm going to assume you're planning on using MySQL and have already setup an empty database and user. The DB user and password are the very minimum you need to install a new site.
The above command will install your site using the "minimal" install profile and give you the username "admin" for the user 1 account. After install, the results on screen will provide you with a randomly generated password so you can log in with the newly created user.
But let's say you want a little more control over the install. Okay, this time, let's provide a different username, site name, install profile, and an e-mail address. The command will now look something like this:
Now that we have a site installed we can extend core by downloading and installing some contributed modules. To download them you only need their project names. For example, if you want to install the Admin Menu module you can find its project name by going to the project's Drupal.org page (http://drupal.org/project/admin_menu) and using everything after "project/": in this case the project name is "admin_menu".
To download this module and additional modules in the same command, you separate the project names with a space, like this:
The result will show you a list of all the downloaded modules available in each package and now you can enable the modules you want to use:
Notice that I didn't just enable Views; I enabled both Views and Views UI. Projects that come packaged with multiple modules are downloaded with a single project name, but to enable all the modules in the same package you will need to type out each module's machine name (e.g.: views_ui for Views UI). I also want to point out that the command "pm-enable" has an alias too. Try using "en" next time.
You can always find out more information about any available command right in the console using help. Just run a command similar to this:
Drush will return a description, the available options and arguments, and often an example. Find help on any command by replacing the above "pm-download" with any command you want to learn about. You can also find out more about these commands at drush.org.
You might not be a Drush master at this point, but you are right on track. Don't worry, young MacGyver, this was just enough to get you started — only one blade in your Swiss Army Knife. There is more to come in the next issue. Until then take what you learned here and give it a try.