Forum topic

1 post / 0 new
Last seen: 5 years 11 months ago
Joined: 06/12/2014 - 14:40
Installing Drush on Shared Hosting Accounts


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.

  1. 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.)
  2. Once you have received SSH access to your site, open a new Terminal and login to your site by typing the following ssh or any additional user login string provided by your Hosting service
  3. Enter your password when prompted
  4. 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.
  5. 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_html/, public_ftp, and a bunch of other files. Make special note of a file named .bashrc, as we will be editing it later.
  6. Download Drush by typing wget (At the time of this edit, the Drush 6 branch is the recommended version and is no longer available for download on Extract the .zip file by typing in unzip 6.x and remove zip file by typing rm
    *Tip: type clear and 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 wget command, you may alternately download the zip file of the recommended branch (currently and manually upload and extract via the host's cPanel File Manager, or an ftp program of your choice.
  7. Type ls again, to list your directory. You should now see drush/ in the directory (if the directory is drush-6.x, rename to drush with mv command).
  8. Type chmod u+x drush to set the correct permissions on the drush command.
    *Tip: Type ls -la to see the permissions and owners on the items in the directory.
  9. 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 .bashrc file. While still in your home directory, type the following: nano .bashrc. This will open up .bashrc in a text editor named nano.
    *note: For GoDaddy accounts there is no nano application (for new cPanel accounts nano is available). Use VIM instead. So type vim .bashrc to edit the file. A good VIM cheatsheet is:]
    Locate # User specific aliases and functions. Underneath that, add the following: alias drush="~/drush/drush". Save the file by typing ctrl+X (Exit) and type y to accept your changes.
  10. Type source ~/.bashrc to refresh the alias list and allow the new drush commands to work.
  11. Confirm that Drush is working by typing drush at the command prompt and hitting enter. You should see a list of drush commands. If you do, then success!
  12. If the previous step doesn't work, type exit to end your SSH session, then log back in (See step 2) to restart your session. This refreshes .bashrc and 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'
  13. 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.

SSH config

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 remote-user.

Editorial Comments

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.

Your rating: None Average: 5 (1 vote)