Drushing a new Drupal


You can use Drush to install a new Drupal installation from scratch. This procedure is adapted from http://www.leveltendesign.com/blog/tom/installing-drupal-7-using-ssh-drush.

The steps are:

  1. Create a new database and user.
  2. Download Drupal core.
  3. Run the Drupal install script.
  4. Add modules and themes.

I assume you have Drush installed, and a directory ready for the Drupal installation.

Create a new database and user

I find it easier to do this step through a Web interface from my host, or with phpMyAdmin. However, you can also do it through the command line:

mysqladmin –u [db_user] –p create [db_name]


mysqladmin –u jimbo –p create doooom

Sometimes your host requires you to name your databases in a specific way. For example, a shared host might require that your databases start with your user name. This separates your DBs from those of other accounts on the same server. If your username was ericaerica, you might type:

mysqladmin –u jimbo –p create erica_doooom

You might have to make it:

mysqladmin –u erica_jimbo –p create erica_doooom

As I said, I tend to use the host's Web interface to make databases. It takes care of this issue for me.

Download Drupal core

cd to the directory where you want to put the installation. Then:

drush dl drupal

This will get the latest version, create a directory, and put all the Drupal files in it.

You can also install a distribution this way. For example:

drush dl cis

This downloads the CIS distribution.

If you ls, you'll see that the files are in a directory like drupal-7.20. Ack! You need to move all the files out of there into your current directory:

mv drupal-7.20/* .

One problem. Drupal comes with two hidden files: .htaccess and .gitignore. The command above might or might not move those files. So:

ls -al

Does .htaccess show up? If so, you're OK. If not, you have to move the hidden files as well:

mv drupal-7.20/.* .

I get an error message from this, but it works. I don't get errors when I move the files one at a time:

drupal-7.20/.htaccess .
drupal-7.20/.gitignore .

Now you can remove the directory Drush created:

rm -r drupal-7.20

Your might need to use rmdir instead of rm.

Run the Drupal install script

Like this:

drush site-install standard --account-name=admin --account-pass=[useruser_pass] --db-url=mysql://[db_user]:[db_pass]@localhost/[db_name]

This uses the standard install profile. You can change that. Here's an example:

drush site-install cis --account-name=admin --account-pass=driBBl3r --db-url=mysql://jimbo:jimbopasssword@localhost/doooom

This installs the cis CIS distribution.

Install modules and themes

You can download modules like this:

drush dl admin_menu module_filter

You can enable them through the Drupal modules page, or:

drush en admin_menu module_filter

That's it!