Thursday, February 09, 2012

Install Drupal Remotely with SSH & Drush

  1. Connect to your server with SSH (using OSX Terminal, or Putty on Windows):
    ssh <username>@<site address>
    See for some background on SSH.
  2. 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):
  3. Use TAR to extract and de-compress the archive, eg:
    tar xzvf drush-7.x-4.5.tar.gz
  4. Set up an alias to Drush
    alias drush='/myserverroot/home/drush/drush'
  5. Change working directory to Public HTML root of server
  6. Download the Drupal code
    drush dl drupal
  7. Move the download 'up' one level (the .htaccess file won't get copied in the blanket move command):
    mv drupal/* .
    mv drupal/.htaccess . 
  8. Remove the original [now empty] directory: 
    rm –r drupal
  9. Create a MySQL database (you may need to do this via your host's control panel)
    mysqladmin –u <db_user> –p create <db_name>
  10. 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>
  11. Fame and glory await
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 to help you: Google is your friend. If you can't tweak php.ini, you may be able to tweak drushrc.php - see for a bit of helpful advice.

No comments:

Post a comment