Last weekend we made a video that shows, hopefully, how easy it is to install Drush, the fabulously powerful command line tool that can drastically speed up developing, installing and maintaining Drupal sites. If you're worried about command line, don't fret. You can type, right? Then you can do command line!
This video covers just installing Drush. It does not get into setting up a local development environment otherwise. There are far too many ways to do that to cover here (but there are some links at the bottom of the post that might help).
The video we made seems to race by in its 2-minute running time, and it may feel like the information is going by too fast. So I've posted the same info, with some more explanation, below.
The Video
The Instructions
Here's the background, step by step, for your reference.
1. Download Drush
[Update: While the video shows downloading the latest stable release, the project page now recommends you download the latest HEAD version. Update 29 March 2010: Drush 3 has reached release candidate stage, so at this point it's probably best to use the latest stable release after all. —LS]
Get it at http://drupal.org/project/drush. Drush works for every version of Drupal, so just find the latest version and download it.
Put the tarball into your working folder. Ideally this is a folder in your home directory. Some people use their "sites" folder for development. I created on my computer in my home directory a working folder called "dev".
Double-click on the tarball to open it up. When you go into the drush folder, you'll see a number of files, including the README.txt file. Read it!
2. Make Drush Executable
Now we venture into the command line. I hope that doesn't vex you, because Drush is a command line tool.
Open your Terminal. This opens up to your "home" directory, which corresponds to the Finder folder that bears your Mac username.
You will want to type the command here chmod u+x /path/to/drush/drush (replacing "/path/to/" with the actual path relative to your home directory). So in my case, with Drush residing in the "dev" folder:
chmod u+x dev/drush/drush
Now that you've made drush executable, you want to set things up so you actually can execute the drush command outside of the actual Drush folder (such as in your working folder for the site you're building). So....
3. Create an Alias
This part may seem a bit mysterious if the Terminal stuff is new to you, but it's really quite simple. We will be adding to your "bash profile" file the path to the drush command so that you can run the drush command from anywhere in your filesystem.
A handy Unix shortcut to your "home" folder is "~/". You can use that in any path designation in relation to the system root.
Find your bash profile file using the Terminal in your "home" directory.
If you're not there, go ahead and enter on the command line:
cd ~/
The bash profile files are hidden from normal view, so to see what files you have in your home directory, enter this command:
ls -a
Your bash profile might be named any of these files. If you don't see any of these in your "home" folder, create one using nano. nano will create the file if it doesn't find one by that name.
You get a list of all the files in that folder. (The "hidden" files start with a dot ".") Look for one of these files:
.profile
.bash_aliases
.bashrc
.bash_profile
Any one will do, so just pick an existing file. (For me, it was .bash_profile.)
Edit the file in the nano editor, the really simple, old school text editor that comes with Unix. Just enter nano [filename]. For me, that means:
nano .bash_profile
This takes you into the editor, and might be looking at one or two lines of code. Cursor down to the end of the file and make sure you're on a new line, and add:
alias drush='/path/to/drush/drush', replacing the "/path/to/" part with the actual path — but this time it needs to be relative to the system root. Now, remember that shortcut to the "home" directory above? Now's the time to use that.
alias drush='~/dev/drush/drush'
Now save the file using <control>-x, y(es), <enter>. Now you're back at your Terminal prompt.
Now all you need to do is reload the updated bash profile using source [filename]. In my case:
source .bash_profile
4. Test
Yes, I know I said it was three steps. But this is testing, and you don't want to skip testing, do you? To test, simply type:
drush
You should get a long list of available Drush commands. You're done! (Or rather, now you can get started!)
Drush it!
Drush Resources
You'll want to dive in and experience Drush Power™! So here are pages you will want to explore.
- The main Drush documentation page (bookmark this) has a list of the basic drush commands.
Pay special attention to the examples at the bottom. I found, for example, that if a drush command wasn't working, pointing to the actual uri for that Drupal instance helped Drush find the appropriate database. Also remember that not all modules are covered in the project name. For example, CCK contains a lot of modules, so you can "dl CCK" but you cannot "en CCK".
- Using Drush to synchronize and deploy sites looks to be one extremely powerful use case for Drush. This is amazing. Anything that makes deployment easier is a big plus in my book!
- Drush Make, an extension to Drush that can create a ready-to-use Drupal site, pulling sources from various locations. It does this by parsing a flat text file (similar to a drupal .info file) and downloading the sources it describes. In practical terms, this means that it is possible to distribute a complicated Drupal distribution as a single text file.
More helpful references on Drush, its installation, its power, and more
- Development Seed's many many posts on Drush are always interesting. If you're interested in Ægir, this is where you want to look.
- Morten "the King of Denmark" Birch Heide-jørgensen's step-by-step post on setting up a local development environment, including installing Drush.
- Lin Clark's video walking through getting started with Drush and Drupal 7.
- Drupal modules that have commands for Drush. This could be very interesting, seeing where this goes.
- RSS feed of Drush releases (because your Available Updates report in Drupal won't tell you about Drush updates that are released).
Hope this is helpful!





Comments
Thank you!! That made so much more sense than trying to interpret the readme!!
I agree, thanks for the great video tutorial! So much easier to follow than the readme.txt file.
Have you tried placing your drush file on an external HD and running it from there? Wondering if this is easy to do or if its best to keep it relative to home directory?
I keep getting command not found for drush..
-bash: drush: command not found
any suggestions.
rs.
Great Tutorial. Thank you.
Thanks a lot ! Great, simple and efficient !
A couple of points.
I only found .bash_profile.save there was nothing in this file but I put the path here anyway and it worked.
If you are in your home directory don't forget the tilde ~ in front of / doesn't work without it.
Now save the file using -x, y(es),
This is actually command in two parts.
1.Press Control and x key simultaneously. The commands at bottom of terminal window show all commands preceded by ^ which is the control key. Useful to know for those of us who have never bothered with terminal.
2. Then at bottom of terminal window option to press y(es) key offered. Press y and the return key
Hope that helps others
Thanks!
Thanks a lot for this tutorial ;)
Have you tried placing your drush file on an external HD and running it from there? I wonder if this is easy to do or if it’s greatest to keep it relative to home directory?
All that matters is that your system knows where Drush is. That said, I have not tried placing Drush on an external drive.
Tnx! Great guide! Saved me a lot of trouble.
Thanks Laura!!
Great tutorial, thanks!!
I didn't grow up in Terminal so getting this fixed took quite some time until I found this tutorial and also the one from MordenDK.
However, it did not work when I used my existing .bashrc, so I created .bash_profile and then it works
Hi Laura -
Just a quick note to thank you for a great, easy-to-follow video on installing Drush.
Without this resource I'd probably still be scratching my head trying to complete this install.
Ken
Thank YOU thank you ... I got used to using Drush in a previous work environment and it came time to start using it again at my current employer. Setting this up without the help of my peers has been challenging until I found this tutorial.
I also liked that you included the text instruction as well, as watching videos isn't always an option in our work environments.
I now have a working drush install on my local machine for development.
Thanks again ... Scott
Post new comment