Learning How to Install Drush on a Non-Admin Rights Server

Mediacurrent Team
Mar
08
2010

Learning How to Install Drush on a Non-Admin Rights Server

Corresponding Blog Image

Recently, I have been working with quite a few Drupal sites, and one of my favorite tools to use has become drush. For those of you who are not aware of it, drush is a command line utility (drush = DRUpal SHell) that makes management of a Drupal site much more bearable. Drush is a great tool to use and is quite simple to install on your system when you have admin rights to the box. However, what about those of us on shared hosting system? For us, we have no admin rights but if you have picked a solid hosting company, you'll have command line access and a .bashrc file (or similar e.g. bash_profile depending on your server distro). Once you have command line access, create a directory on the server where you'll keep any programs you choose to install. I created a "bin" directory in my user's home. mkdir bin Once you've created that directory, use wget and the link to the latest drush version to download the tarball. wget http://ftp.drupal.org/files/projects/drush-All-versions-3.0-beta1.tar.gz Once it downloads, extract it. tar xzvf drush-All-versions-3.0-beta1.tar.gz cd into the newly created directory and make sure the drush* file is executable. If not, chmod u+x drush Now you have drush on your system it would be quite cumbersome to have to type the full path to the executable as well as the drush options. In order to alleviate this we have two choices: (1.) we can either export our PATH or (2.) setup an alias in our .bashrc file. I choose the latter, but I'll show you both options. First, however, you'll need to know the full path to the drush executable. Inside your ~/bin/drush directory, execute the following: pwd So your full path will be something like: /home/mysite/bin/drush/drush Onto setting up the shortcuts to only have to type 'drush' PATH option: export PATH=$PATH:/home/mysite/bin/drush .bashrc option: vi .bashrc Inside the file, you'll add an alias (press 'i' to enter insert mode) alias drush='/home/mysite/bin/drush/drush'then save the file (type :wq) The downside to using the .bashrc option is that you'll have to start a new terminal session to begin using the alias (or type the same alias in the command line so you can use this session then any other session you start it reads from the .bashrc). thus, you should exit then fire up your terminal again. From here you can execute the entire suite of drush commands simply by using the word 'drush' followed by any drush options just like you would in a normal drush install. To recap, simply:

  • open a terminal on your server
  • create a bin directory
  • download and extract drush into the bin directory
  • ensure drush is executable
  • get the full path to the executable then either
  • 1) add the full drush path to your PATH variable
  • 2) alias drush to the full drush path and restart you terminal session

*note: instead of executing a pwd to get the path to your drush install, you could use ~/bin/drush/drush if indeed your bin is in your home directory but I think it's best practice to use full, human readable paths to alleviate any ambiguity. Hope this helps!

comments powered by Disqus