Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Installing Drush on *nix

0 (0 Likes / 0 Dislikes)
[robotic voice] Drupalize me. [ - Learn Drupal] [Installing Drush on *nix - With Addison Berry] Hi there. In this video we're going to be looking at how to install the Drupal utility called Drush, which you can find on at This is a command-line tool, which is really, really handy, but it requires a little extra thought and work when installing than a typical Drupal project does. So let's take a look at what we need to do. Before we actually dive into the installation itself, let's take a moment to make sure we have the requirements that we need. This is covering only installation on *nix systems like Linux, Unix, or Mac OSX. We're not going to talk about Windows in this video; we'll have another one for that one. And we want to make sure that we have PHP at least at 5.2 with a command-line interface. And, of course, you also will need access to an actual command line. It's a command-line tool. So what we're going to do is real quickly I just want to check and make sure that my PHP version is correct. So I'm going to open up terminal, which is my command line on-- I'm on a Mac--and I'm going to type in php dash v to get the version information for my PHP that I'm running from the command line. And you can see it tells me the version, the full version number, so I definitely have 5.2, and it also indicates that it is CLI, but I wouldn't have been able to access it without that. So I'm good with my PHP. Obviously I have access to the command line. And I am on a Mac for this example. Now, these are the 3 basic steps for installing Drush, and we'll run through them and then we'll break it down step by step through the video. First we need to actually get Drush, so we need to download it from Then you need to make it executable. This is actually a script that you're going to be running, so it has to be able--your system has to be able to execute the script in order for it to work. And then we're going to talk about the Drush path so that you can run the Drush command from anywhere on your system without having to know the full path to where this actual script sits. We kind of want to make it universally available on our computers. Before we get started, I just want to show you how you can find all of these installation instructions yourself easily on-line. If you go to the Drush project page, there's a link to, and they have an FAQ there that has a link to the readme.txt file that is actually packaged with Drush when you download it. But you can read it online by going to the site. It has the requirements we just talked about, the installation steps, and in addition--it's quite a large file-- if you keep scrolling down it has additional things for like if you're configuring it on MAMP and other AMP stacks. So there are different configurations for different set-ups. There is a lot of information in this file. Okay. So let's do step 1, download Drush. There are several ways that you can download Drush. It's all going to come from's project page. You can get the actual tarball or zip file from the project page, and you can do that either by clicking-- like, you know, if you just went to a site and click the download, or you can use FTP or wget on the command line , so you don't have to do it through a graphical user interface. Or, you can also--if you have Git you use Git to just get a clone of Drush, and then you can easily update by using Git, which is a really handy way to do this. What we're going to look at here is we're going to actually use the command line to download the tarball--do it that way. It's a command-line tool; you're going to need to use command line anyway, so you might as well start early. So I'm going to start off on the project page for Drush, and I'm going to point out a few things before we get to the download. One is that you can see that Drush is independent of Drupal version, so you can really sort of download any of them and it's going to work for you. If you come now to the download, you'll see there is a 7x-4.5, so 4.5 is actually the version of Drush, the 4 series. There's a 4x and a 5x for development; those are two different versions. We're going to go ahead and just stick with the official recommended release here, and you can see there is a tarball and a zip. You can download whichever one floats your boat. The other way that you can get a download of Drush is if you click on the version control tab on the project page there is information on how you can pick your version, and again we'll just go with--you know--I'll just show you the normal version that you should get. You'll see that there's a command; you can just copy and paste this Git command. You need to have Git installed on your computer for this to work, but if you do it's a really quick, simple way to get a copy. We're going to do our download by getting the tarball, but I'm going to get it from command line rather than clicking and saving it. So I'm going to copy the link location; I've right-clicked on that link and got the actual link location for where that download is. And now I'm going to go back to my terminal and use that to download it from the command line. Now I'm going to--this is my home directory, and you'll see I have a Drupal folder in here, so that's where I'm going to put my Drush download. You can put Drush anywhere you want on your system that you have access to. It doesn't matter. You just need to pick a place that makes sense to you. So I'm going to use the FTP command. You can also use wget on a lot of systems--on Linux systems. Mac OSX doesn't have wget by default, but it does have FTP, and so I'm going to use FTP. When I paste this URL in, you can see it's using an FTP server on So I can use that from the command line to grab this file, so I'll go ahead and run that. And now if we look in here you'll see I have a tarball that's been downloaded. And now I just need to uncompress this. Since it's a tarball, I need to use the tar command. If it was a zip I could use the unzip command, which--get whichever one you are more comfortable with. So I'm going to extract this tarball, and I'll run that command. And you can see it opened everything up and put it into a nice, handy Drush folder for me. So let me clear some of this stuff out. You can see--so I have my Drush folder and then I have that tarball in there. That's all I need to do to download Drush and get ready to play around. If we go into the Drush folder, we'll take a look at the files. You can see the actual Drush script is located in here, just called drush. And there is also that readme.txt file as well, so once you've downloaded Drush you can read that entire readme file, and you have all the installation instructions. So if I just open that up here real quickly, you can see here are the same installation instructions we saw on the online version of it. So you have access to that stuff right here on your local machine now. Okay, so now that we have it downloaded, we need to make the Drush script executable. It's a script, so our computer needs to have permissions in order to actually run the script in order for it to work for us. So here's the typical command; we need to chmod the Drush script. You may or may not need sudo depending on your user permissions for doing these things. But we do need to chmod and add executable rights to the Drush script, so let's hop back over to terminal and see how that looks and works. I'm going to do an LSAL so we can see all the permissions on the files in my Drush folder here. And you'll see here's the Drush script, and you can see the permissions that are listed all the way to the left. And it already has the executable. You can see there's an R, W, and X; that's read, write, and executable permissions. So for the user it already has read, write, and executable. So this script is actually already capable of running, but you need to double check that, and if you don't have the executable on there, what you need to do is do a chmod command to add it. So we would chmod, and then for the user we want to add executable, so that's u+x (user add executable) and then the name of the file, which is drush. I don't need to actually run this myself because it already is executable, but if you do run this command, double check it again to make sure that it is actually executable, and you should be good to go. Very important step that some people miss and makes them a little crazy. Let me clear this screen out here. I just want to real quickly show that this actually works, so you can see I'm in my drush folder, which is where the drush script lives. And I can run the script by doing dot slash drush (./drush). I have to say where the file is, and you can see Drush is working. So dot slash simply means in this directory, run the drush script. And I did, and I'm getting help text from Drush, so it's working, which is awesome. So we are pretty much there, except that--let's talk about paths. I can type Drush currently and use Drush inside of that directory, inside my Drupal Drush directory. But I can't just go anywhere willy-nilly and type the word "drush" and have it work, and there are two ways that we can add this. And this is just one of those things that's just super convenient, so you might as well do it. And we can either create a symbolic link or we can add the drush path to our path variable on our computer. We're going to talk about what both of those mean and how to do both of those so that you don't drive yourself crazy having to type full paths out everywhere. Okay. So, back on the command line. I'm going to just go to my home directory, so you can see I'm just--I'm not in the drush directory anymore. I'm just in my home directory. If I type the word "drush" nothing happens. If I do ./drush, nothing happens because the script isn't located here and it doesn't know where to find it. So if I'm not actually in the drush directory, I'm kind of limited. The way that I could run it from anywhere is to type the entire path to the drush script, anytime I wanted to use it. So I could type this out. So I'm in /Users/add1sun/drupal/drush/drush and if I type that out it works because I'm telling my computer the entire system to where it needs to go, but you would have to type that out every single time you wanted to use drush. That is a pain. So we're going to make it so that we can just type the word drush and be done with it. To understand what we're doing here, we need to talk about paths. Your system has a path variable, which is a list of all of the paths that it will execute scripts from, essentially. So if you echo $PATH, you can see what your current settings are, and you see there are a bunch of paths separated by colons. The most common ones for our use case here where you would want to put your script so it will run is user/bin or user/local/bin. They already exist, and I can just sort of re-use that. But instead of actually physically moving my drush script into one of those directories, I can use a symlink so that the computer thinks that the script is there and will therefore execute it without me having to move things around. I want to keep them organized the way I want to. So I'm going to do a symlink, one simple command here, so it's link dash s, for symlink or soft, and then I need to put the path to my script--to the drush script. So the full path here is /Users/add1sun/drupal/drush. Drush is the folder. Remember there is a folder that holds the drush script. And then there is a drush script inside of that, and I need to put the actual script I'm pointing to, not the folder because a folder's not executable; it won't do anything. So then slash drush for the script name. So drush/drush. It looks weird, but that's what we need to do. And then where I want it to be, where I want it to be located, which is /user/local/bin/drush. I'll type in the drush command name there. You know--you could put in something silly like dr, but I'm going to use drush so I know which command I'm talking about. And when I do that, now if I type the word "drush" the command will execute. It knows it's now going back, following that symlink and going back to the actual drush script and running it, and so it works great, which is awesome. Now the other way of approaching this is to update our path variable ourselves, like actually add the drush path to that path variable. So to see how this works, I'm going to just remove the symlink so we can tell when it's working or not working. And now if I do drush it won't work anymore, so I'm back to where I was. Now what I want to do is actually edit my path variable. You do this in different files on different systems, but normally you have like a user file where you have user configurations for your shell, and that's where you would set your path, your custom path stuff. I'm currently in my home directory, and if I look at all the files including the hidden files, the ones that start with a dot in front of them, the bash profile is the file that I have my custom path configuration in. So I'm going to edit my bash profile, whichever file you need to on your system is where you would do this. Use whatever editor you want to. I use vi. And if this file doesn't exist for your system, go ahead and create it in your user directory. And you can just add the information that you need. So this is the line where I'm adding paths. You can see I'm actually adding some paths from MAMP in here that I wanted to have executable without having to type all that stuff in. So I've actually already added some things, and then I pre-pended that to the existing path variables. That's very important. You don't want to override, you want to add to. So make sure you have the path variable at the end there, as well. The colons are important as well; that separates each path. You don't want it to all run together or it won't work. So I'm going to insert a colon to start a new section for a new path I'm entering. And then the path that I need to enter is my drush folder. Again, this is not the script. This is the container that holds things that I want to execute. So I can just put the folder in this, whereas in the symlink I put the script. It's a fine distinction but important. Once I've added this into my path variable, using this syntax here to make sure that system knows about it, I'm going to go ahead and save that. And if I try to run the command right now, it's actually not going to work yet, and that's because whenever you update these kinds of profiles shell profiles, you need to restart a session on the shell in order for it to pick up the changes you have done. So I'm going to close my window and open it up again. And now that I've started a new shell session, now the changes are in there and now it works. So that's something also that tends to hang people up a little bit. But now it's working. I can type the word "drush" from anywhere in the system, and it will execute it. And now I'm ready to go nuts using this wonderful, wonderful tool called Drush. And we have more videos to talk about the specifics of actually using Drush. So now that you're up and running, time to go play. [] [Learn Drupal]

Video Details

Duration: 16 minutes and 23 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 47
Posted by: drupalizeme on Oct 3, 2012

In this video we walk through the steps to install Drush on *nix system (i.e. Linux, Unix, or Mac OS X). Drush is not a normal Drupal project and the installation and set up is quite different than for a module. We cover requirements and downloading, then make sure Drush is executable and in our system $PATH variable so we can use Drush from any directory.

Caption and Translate

    Sign In/Register for Dotsub to translate this video.