If you don't use the command line in the course of your web development work, spend the time to become familiar with some basic commands. Not only will it save you untold amounts of time and effort, it'll make you feel like a hardcore hacker.
As is often the case, jobs sometimes require installing and developing your Drupal site on a shared environment that you don't have root permissions for. While installing Drush on a server you have full control of is fairly straighforward, installing on a shared environment takes a few more steps.
Let's dive right in and see what's involved.
Prefatory note: If your web host doesn't allow shell access to its shared servers, you're out of luck and should think about using a different host. Yes, really.
- Open a terminal window (or terminal emulator in Windows), log in to your server, and browse to home directory of your account. Type the command:
and press Enter to see the contents of the current folder. You'll know you're in the right directory if you see /public_html or /www in the list of files and folders. If not, change to the level above by entering:
That will take you up one level in the directory structure. Repeat that process typing 'ls' each time, until you see you're in the right directory.
- Look for the /bin directory. This is usually created by default with shared accounts, and contains the commands and utilities that you use to work on the server. When you see /bin listed, change to that directory by typing:
If it's not there, create it by typing (at the prompt):
- Change directories so that you're in the newly created folder, again using the
command, and download the tarball of latest version of Drush by typing:
The file name of the tarball might be different, but you can find the latest version of the project at http://drupal.org/project/drush.
- After the tar file downloads, extract it by entering:
tar xzvf drush-All-versions-x.x-xxxx.tar.gz
Then delete the tarball by entering:
- Change to the /drush/ directory by entering:
and then enter:
chmod u+x drush
This ensures the drush file has the permissions is needs to be run when it's called.
- So that we don't have to write out the full path to the Drush executable each time we want to use a Drush command, let's create a path to the Drush executable by making a path link. First, make sure you're still in the Drush folder and then type:
The path to the current directory will be printed for you. Copy the path, which might look something like
and then execute:
- Check that Drush has been successfully installed, and your link created by entering:
on the command line. If you see a list of all the Drush commands listed on the screen, you're ready to roll with Drush!