Drupal Template Installations

This post describes the work I have done to create "template sites".  Template sites are Drupal installations created and maintained with initial setup done to speed the creation of a new site.  The template sites can be duplicated onto a new domain and database loaded with a single simple script.



When I start a new site, there are certain things that always have to be done (no matter the nature of the site):

  • I have to install Drupal core.
  • I have to install my favorite contributed modules.
    These are the modules like views and ckeditor -- modules I use on every site I build.
  • I have to configure Drupal and all those modules.

These are repetitive tasks, and repetitive tasks chafe.


Instead of repeating these tasks every time I need to create a new site, I instead clone a template site which includes all this initial state.

These template sites (I have one for Drupal 6 and Drupal 7) are basic installations.  They have (almost) no content, no users (besides uid=1), no additional themes installed.  They were created using my drupalDeploy.sh script (and thus compatible with my Drupal Scripts Library). The sites are kept patched on a reasonable schedule.

These template sites have the following items/features/what-not installed on them and configured:

  1. ckeditor and imce modules installed and configured with a single (full) profile.
  2. The logintoboggan module enabling email logins (not configured to grant instant access).
  3. An initial 'Site Admin' book page created to host site information.  This book is limited to authenticated users using the book access module.  This page is set to be the initial login page using the login destination module.  A menu for the pages in this book generated in a block shown for authenticated users. Because the page is password protected, users can simply bookmark http://<sitename>/siteadmin.  If they are not currently logged in, the logintoboggan module will challenge them to log in.
  4. My scheme to support anonymous comments (only the part about the the better formats module).  (Note: the Better Formats module is currently unsupported in Drupal 7.)
  5. admin block and admin menu modules installed and enabled. (I prefer admin menu to the the D-7 toolbar module and overlays.)
  6. Other modules installed (and possibly enabled): advanced_help, jquery_ui, pathauto/token, tableofcontents

I have a cron job running on my server which re-generates the tar files listed below every night.  These tar files include not only the Drupal core and installed modules; but a database dump as well.  This dump is generated with the drupalBackup.sh script (which calls the drupalDBBackup.sh script) and exists in the 'sites/<sitename>/backups' directory.  These tar files are linked to this node (and are visible at the bottom of the page).

Also: I do know about drush make; but I find this a more convenient way to solve this problem.  Because the template sites are live sites, I can maintain them and add additional features to them as I wish.  Then, as soon as the nightly cron job is run, the template file is updated.

Working With Template Sites

To facilitate using these sites, I wrote the new script drupalBootstrapTemplate.sh which will download one of the template files attached to this node and install it on a new domain name and database.  The script takes as parameters a flag denoting selected Drupal version, the (domain) name of the new site, and the database connection parameters.

After the script runs, the new site will be installed on the given domain name and the database will be initialized.  The root (uid=1) user for the new site is 'admin' and the user's password will be set to the database connection password.  (This is described in the Drupal Script Library's README file -- see the 'General Concepts' section.)

NOTE: Because of current limitations of the drupalBootstrapTemplate.sh script, you have to do the following things manually after completion of the drupalBootstrapTemplate.sh script:

  • For Drupal 6 sites - log in, hit the CKEditor configuration page ('/admin/settings/ckeditor'), edit the "Advanced" profile, then save it directly.  This is to correct a file path on the ckeditor_settings table.


Free Tag: