NOTE: I'm getting reports that Git is now necessary to install Drush via Composer. I have not been able to confirm these. If you know anything about this, or have experienced this issue, please comment below.
Drush 6.2 and above require the Composer Dependency Manager. This guide will get you up and running with the latest versions of Drush on your Shared Hosting account. To install a previous version of Drush, see Installing Older Versions of Drush on Shared Hosting Accounts.
This guide is specific to Linux / Apache shared hosts. While it is possible to install Drush on a Shared Windows Server, the commands below are Linux-specific and will not work on a Windows Web Server. Please note that specific locations of files may change based on your host's environment. If you discover that your host keeps files in a different place, please note that in the comments below.
Requesting SSH Access
In order to use Drush, you will need SSH (Secure Shell) access to your shared hosting account. The process for enabling SSH will vary between hosts, and some hosts won't allow SSH access at all. In many cases, you can turn SSH (or Shell) access on via your account's control panel, or by submitting a support ticket. Refer to your host's Knowledge Base or Support Docs for more information.
You will also need an SSH Client. If you are on Windows, you can download PuTTY, a free SSH client for Windows. Mac users can just use Terminal, which is preinstalled. Firefox users on either platform can install the FireSSH extension. Chrome users on either platform can install the Secure Shell extension.
After gaining SSH access, open your SSH Client and login to your shared hosting account using the credentials given to you by your host. For Terminal users this will be
You will then be prompted for your password. PuTTY users have a slightly different login process. Please refer to the PuTTY help docs if you get stuck.
You are now logged in to your server using an SSH Client. On a Linux server, this shell program is called Bash, and commands are referred to as Bash commands.
Familiarize Yourself With Your Shared Hosting Environment
Take a few moments to try and locate some of the files and directories you will need to correctly install Drush, as they may not be in the exact same places listed here. This will help you follow the rest of this guide.
cd ~. This will change directories and move you to your home folder. Then, type
clear. This will clear all old commands out of the shell and and make it easier for you to read the screen. Use this command as often as you need.
ls -a. This will list all files and folders (including hidden folders) within your home directory. Look for a file named .bash_profile, or .bashrc. Some systems have both.
Please note: some Web hosts that use Free BSD or other UNIX operating systems may not have a .bashrc file, but a .cshrc file, which you edit in the same manner.
We will use .bash_profile in this guide, but if you only have .bashrc, then use that one. If you have neither, please consult your host's Knowledge Base or Support Docs to find out how to add Bash aliases on your server.
Finally, look for a directory named bin/. Directories have backslashes after them and most SSH Clients display them in a different color than files. If you don't have a bin/ folder, try to follow this guide by removing any reference to bin/ from what you type.
Make sure you are still in your home directory by typing
cd ~ and hitting enter, then type the following command into your shell:
curl -sS https://getcomposer.org/installer | php
This will download the installer from Composer's website and use php to run the installer. If you get a message saying curl is not installed, then replace
curl -sS with
wget and try again. If neither
wget is installed on your system, try the following command:
php -r "readfile('https://getcomposer.org/installer');" | php
If successful, you should get output that looks something like this:
All settings correct for using Composer Downloading... Composer successfully installed to: /home/[username]/composer.phar Use it: php composer.phar
If you do not get a similar message, your host may not be set up to correctly install Composer. Please refer to their support pages for additional information.
Some shared hosts run an older version of php from the command line by default. If you encounter this problem, you can set up an alias in .bash_profile (or .bashrc) to use the more current version of php that your web server is using. At the bottom of the file, add this line:
alias php='path/to/php'where path/to/php is the path to the version of php your web server is running. Google how to find this path.
Next, we will move composer.phar, the file you just installed, to keep our home directory clean:
mv -p composer.phar ~/bin/composer.phar
Then, we will add a few lines to .bash_profile (or .bashrc) for ease of use. First, type
nano .bash_profile to open .bash_profile up in the Nano text editor. For help in using the Nano text editor, visit here. Add the following line to the bottom of the file:
alias composer="/usr/php/54/usr/bin/php-cli ~/bin/composer.phar"
This sets up a command in bash that runs the script located at "~/bin/composer.phar" with the program located at "/usr/php/54/bin/php54-cli", in this case, the php-cli program. Not all hosts will have php-cli located at this location. Some hosts might not even have php-cli installed. You can check to see if php-cli is available and if so what the path to the program is by typing
which php-cli at a command line prompt (NOTE: Not in Nano). If php-cli is available, this command will return the path. If it is not available, it will return nothing.
After adding the above alias to .bash_profile, type
ctrl+x and follow the prompts to save the changes to this file.
Finally, you will need to reload your aliases for the new command to work. Type
source ~/.bash_profile (remember to substitute .bashrc if that is where you put the alias!) then hit enter. Type
composer to see if Composer is working. You should get a list of options if it is. If the command returns...
-bash: composer: command not found
...then try closing your SSH Client entirely, reopening it and logging back in. If the
composer command still doesn't work, verify that you typed everything correctly in the preceding steps. If you get a specific error message, please leave a comment here.
Congratulations, the hard part is over. If you successfully installed Composer, then installing Drush will be simple.
Drupal 8 requires Drush 7, so we will install the latest master from the repository. Type:
composer global require drush/drush:dev-master
If you need a different version of Drush, you can alter this command by specifying a version number:
composer global require drush/drush:6.4.0
That's it! Drush is now installed on your system. To make it easier to use, add another alias to your .bash_profile or .bashrc file by typing
nano .bash_profile and then entering the following:
ctrl+x and follow the prompts to save your changes. Then reload the file by typing
source ~/.bash_profile (or .bashrc, if that's where you made the changes), or simply closing your SSH Client and logging back in again.
drush to see if your installation is working. You should get a list of options and some other drush-specific information.
If your shared host has different locations of files, but this guide works in general, please add a comment below with the specifics of your host. If your host requires completely different instructions, please create a new child page and add the instructions there.