This page does not yet reflect new changes to Drush that apparently make Composer a prerequisite to Drush installation in the newer branches. I don't have time to explore this right now. If you have the knowledge, please update this page to reflect that, then remove this message. In the meantime, users of this page can still install older versions of Drush using this method.
Some instructions on installing Composer can be found in the comments.
- If you don't already have shell access, request access to SSH for your shared hosting account (e.g. for Hostmonster or Green Geeks: open a new support ticket with 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 email@example.com any additional user login string provided by your Hosting service
- Enter your password when prompted
- By default, you should be in your home directory (~). If you are not in your home directory, navigate yourself there by using the
cd ~(cd = change directory command). 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 https://github.com/drush-ops/drush/archive/6.x.zip(At the time of this edit, the Drush 6 branch is the recommended version and is no longer available for download on drupal.org). Extract the .zip file by typing in
unzip 6.xand remove zip file by typing
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**Important: If your host's configuration does not allow for the
wgetcommand, you may alternately download the zip file of the recommended branch (currently https://github.com/drush-ops/drush/tree/6.x) and manually upload and extract via the host's cPanel File Manager, or an ftp program of your choice.
lsagain, to list your directory. You should now see
drush/in the directory (if the directory is drush-6.x, rename to drush with
chmod u+x drushto set the correct permissions on the drush command.
ls -lato see the permissions and owners on the items in the directory.
- Next, in order to use Drush across our installation&emdash;in all of our sub-folders&emdash;we need to add a line to our
.bashrcfile. While still in your home directory, type the following:
nano .bashrc. This will open up
.bashrcin a text editor named
*note: For GoDaddy accounts there is no nano application (for new cPanel accounts nano is available). Use VIM instead. So type
vim .bashrcto edit the file. A good VIM cheatsheet is: http://www.fprintf.net/vimCheatSheet.html]
# User specific aliases and functions. Underneath that, add the following:
alias drush="~/drush/drush". Save the file by typing
ctrl+X(Exit) and type
yto accept your changes.
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 GoDaddy (legacy accounts) 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:
export COLUMNSalias drush='/usr/local/php5/bin/php ~/drush/drush.php'alias php='/usr/local/php5/bin/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 or Green Geeks, 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.
Since you'll be using the ssh login prompt a lot, you might consider creating a local alias for your login credentials. Follow this link for detailed instructions. Note that in a Drush site-alias configuration you would use the host name configured in this file as
remote-host and no
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.