- If you don't already have shell access, request access to SSH for your shared hosting account (f.e. for Hostmonster: open a new support ticket with Hostmonster Tech Support (UPDATE: Shell access can now be enabled from cPanel for some hostmonster hosting accounts). For other Hosting services you may need to upgrade to use SSH.)
- Once you have received SSH access to your site, open a new Terminal and login to your site by typing the following
ssh firstname.lastname@example.org any additional user login string provided by your Hosting service
- Enter your password when prompted
- By default, you should be in your home directory (~). The
'~'is an alias for your home directory. On Hostmonster, and nearly every other Linux shared hosting situation, your website directory is located at ~/public_html or more specifically /www/htdocs/username
- Confirm you are in your home directory by typing the bash shell command
ls, which will list the files and folders in the current directory. On Hostmonster, you should see
public_ftp, and a bunch of other files. Make special note of a file named
.bashrc, as we will be editing it later.
- Download Drush by typing
wget http://ftp.drupal.org/files/projects/drush-7.x-5.8.tar.gz, replacing drush-7.x-5.8.tar.gz with the current link. The easiest way to do this is to go to http://www.drupal.org/project/drush and right click on the tar.gz download link, then select "Copy link location" (or the IE equivalent), and simply paste it after
wgetin the terminal. Hit
enterafter completing this step, and watch as the command line downloads the tarball to the current directory
- Next, type
clearand hit enter. This will clear your screen, and give you a little more breathing room. Do this as much as you want to throughout this process
- Now that you have a nice clean screen to work with type
lsagain, to list your directory
- Highlight and copy the drush tarball listed
- Next, run the following command, pasting your tarball in place of the one listed here:
tar -xvzf drush-7.x-5.8.tar.gz. Watch as the tarball is unpacked
lsagain to confirm that you now have a folder named
drushin your home directory
- Delete the tarball by typing
rm drush-7.x-5.8.tar.gz. Make sure to substitute the tarball listed for the one you downloaded.
- Next, in order to use Drush across our installation, in all of our subfolders, we need to add a line to our
.bashrcfile. To do this first confirm you are still in your home folder (
cd ~) and then type the following:
nano .bashrc. This will open up
.bashrcin a text editor named
# User specific aliases and functions. Underneath that, add the following:
alias drush="~/drush/drush". Save the file by typing
ctrl+O(O as in Omega, not the number 0). Exit
source ~/.bashrcto refresh the alias list and allow the new drush commands to work.
- Confirm that Drush is working by typing
drushat the command prompt and hitting
enter. You should see a list of drush commands. If you do, then
- If the previous step doesn't work, type
exitto end your SSH session, then log back in (See step 2) to restart your session. This refreshes
.bashrcand allows the new drush commands to work. Some hosting providers such as Go Daddy use php-cgi in the command line instead of php-cli. The former is not compatible with Drush and if this is your case you have to locate php-cli and then add the following lines to your ~/.bashrc or ~/.bash-profile file:
alias drush='/usr/local/php5/bin/php ~/drush/drush.php'
- You have now added drush hot sauce to your shared host. Awesome!
Once again, this should work on any shared hosting Linux platforms that allow shell access. On Hostmonster, you have to specifically ask them to turn it on. If you do not have a
.bashrc file in your home directory, try making it by typing
touch .bashrc. You can also try using a file named .profile, .bash_aliases or .bash_profile, depending on your server's setup.
For all those who didn't really understand the instructions and are just trying to follow it as it is written, here's a bit of advice: only use Drush if you start to understand it, even a little bit. Shell commands and Drush commands are very powerful and not recommended for learning on production sites or sites with a live server deadline, because you can mess things up very quickly. Your Shared Hosting support won't be happy if you create code loops through failure.
Another bit of advice: If you are not a full-time developer, you should always use the stable non-beta releases of Drush, and should never use the additional -y command to avoid the security question "are you sure you want ... ? y/n.
To put it another way: Read the instructions twice, understand what the commands mean and what they do, don't rely solely on copy/paste. In the long run, you will save your self time--which is the whole point of Drush in the first place.
Let's take the alias command as an example; you can exchange the .bashrc alias line with something else like
alias ddd='~/drush/drush' instead of
alias drush='~/drush/drush'. This actually changes the way you use the Drush command later. Your commands will start with ddd [your command] then, instead of drush [your command]. And you can also add other aliases of course, like:
alias dddl='~drush/drush en' , which simplifies thee often-used Drush 'en' command from
drush dl to
dddl. In short, it is well worth your time (and safer) to go ahead and learn how to properly use Bash commands, if you plan on using Drush.
The Drush Documentation is a great place to start. It will teach you about Drush commands, and how to use them.