Install Drupal Remotely with SSH & Drush
A brief guide on how to make yourself more productive by using the command line to install Drupal on a server: either a local, development or live system.
- Connect to your server with SSH (using OSX Terminal, or Putty on Windows):
ssh <username>@<site address>
See en.wikipedia.org/wiki/Secure_Shell for some background on SSH.
- In your server root directory - preferably not the 'Public HTML' directory, WGET the Drush tarball of the latest release of Drush (currently at release 4.5):
- Use TAR to extract and de-compress the archive, eg:
tar xzvf drush-7.x-4.5.tar.gz
- Set up an alias to Drush
- Change working directory to Public HTML root of server
- Download the Drupal code
drush dl drupal
- Move the download 'up' one level (the .htaccess file won't get copied in the blanket move command):
mv drupal/* .
mv drupal/.htaccess .
- Remove the original [now empty] directory:
rm –r drupal
- Create a MySQL database (you may need to do this via your host's control panel)
mysqladmin –u <db_user> –p create <db_name>
- Install the Drupal site
drush site-install standard --account-name=admin --account-pass=<useruser_pass> --db-url=mysql://<db_user>:<db_pass>@localhost/<db_name>
- Fame and glory await (sorry, this solution goes to 11).
For more advice and a screencast, go to LevelTen's site, for a great post by Tom McCracken.
Only snag I've had with some hosts is providing enough resources for PHP/Drush to execute commands: 'Out of memory' a common problem, especially on shared hosting which may have relatively low memory. 256MB seems to be the minimum you can get away with to allocate to PHP [for Drupal/Drush] to run, so make sure when you purchase a hosting package, that you can have enough memory to play with.
If you have messed about a bit with Drush, you can check where your version is stored by running
which drush on the command line. In this directory you may need to add a php.ini file that has suitable settings (eg memory_limit). Lots of issues on drupal.org to help you: Google is your friend. If you can't tweak php.ini, you may be able to tweak drushrc.php - see www.mcdruid.co.uk for a bit of helpful advice.