This chapter shows how common site-building and administration tasks in Drupal projects can be performed faster and easier using Drush commands, right after it has been installed. In order to demonstrate this, a sample Drupal project will be installed, configured, extended, archived, restored, and monitored using Drush commands. Get ready to dive into the terminal and start typing rather than clicking!
We are about to download the latest Drupal 7 version available, to be the foundation of our test project. Let's call it Festival: a site to promote our favorite music festival.
Almost everything in the rest of the chapter is compatible with Drupal 6. Whenever there is a difference, it will be pointed out.
The first thing we need to do is to download Drupal core into a directory which will be our root path. Here is an example of how to achieve it:
$ cd /home/juampy/projects
$ drush pm-download --drupal-project-rename=festival drupal
Project drupal (7.10) downloaded to [success] /home/juampy/projects/festival.
Project drupal contains: [success]
- 3 profiles: minimal, standard, testing
- 4 themes: seven, stark, garland, bartik
- 47 modules: simpletest, shortcut, text, list, number, field_sql_storage, options, field, forum, node, help, contact, php, book, aggregator, dashboard, toolbar, syslog, taxonomy, user, filter, rdf, dblog, menu, path, translation, comment, field_ui, color, trigger, locale, openid, statistics, search, contextual, blog, block, poll, update, file, overlay, image, profile, system, tracker, drupal_system_listing_incompatible_test, drupal_system_listing_compatible_test
The pm-download
command outputs a description of what version it has downloaded and its contents. We have used the --drupal-project-rename
option to rename the generated directory from drupal-7.10
to festival
.
Now, we are going invoke the Drupal installation process. Without even opening the browser and just by typing one Drush command we will obtain:
festival
with the basic data for our site defined by an installation profile called standard
sites/all/settings.php
file configured and pointing to a database sites/all/files
directory ready to be used by the websiteFirst we will execute it, and then we will go through its syntax and output in detail. Note that you have to replace the username and password strings in the command with an existing MySql's username and password (normally, this is the root user for local development environments):
$ drush site-install --db-url=mysql://username:password@localhost/festival --site-name=Festival standard
You are about to DROP your festival database and then CREATE a new one. Do you want to continue? (y/n):
Unless you already have a database with the name festival
, you can safely accept the warning. This will start the installation process:
Starting Drupal installation. This takes a few seconds ... [ok]
This command installs a Drupal site in our system. We provided with it the following arguments and options:
profiles
directory to be used instead.Once the process completes, we only need to configure our web server so a local URL (for example, http://festival.localhost) that resolves to the root directory of our project (which is /home/juampy/projects/festival
for this example). It is outside of the scope of this book to instruct you how to do it, but, in case you need it, you can find a lot of useful information at http://drupal.org/node/157602. Once you have set it up, open your web browser, type http://festival.localhost in the URL address field and hit Enter. Here is an example of how our website looks like when opening it for the first time:
The site's homepage is presented. You can log in as the administrator by typing admin in both the Username and Password fields at the User login form.
site-install
has plenty of options available. Here are some command examples and a description of what their output would be:
sites/drupal.localhost
instead of sites/default
for the site configuration:$ wget -O profiles/standard/translations/drupal-7.10.es.po http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.10.es.po
$ drush site-install --db-url=mysql://username:password@localhost/drupal --site-name="Spanish Festival" --locale=es --sites-subdir=drupal.localhost standard install_configure_form.site_default_country=ES
admin
account:$ drush site-install --db-url=mysql://username:password@localhost/drupal --account-name="Webmaster" --account-pass="W3bm4st3Drpl" --account-mail="[email protected]" standard
$ drush site-install
--db-url=mysql://username:pass@localhost/drupal
--db-su=root --db-su-pw=rootPassword standard
18.218.55.14