Drupal multi-sites in a nutshell

Although Drupal multi-sites are conceptually trivial, I found no satisfactory (short!) explanation in the official documentation or on the web. You can listen to this half an hour long presentation like I did, but I'd rather have read the following summary. I suppose you're already familiar with single-site Drupal setups and would like to understand multi-site now:
  • A multi-site configuration consists of a single code base along with multiple databases. Essentially, there is one database per site, although relocating some shared tables to a common database (in the same database server) is also possible. This approach should be contrasted with a shared-nothing "multiple site" configuration.
  • The key to the entire concept is how Drupal locates the settings.php file based on the requested URL. You can steer it to a different settings.php (hence, a different database) for any combination of hostname, port and URI prefix. The exact lookup algorithm and naming conventions are described in settings.php itself.
  • There is no "master" configuration or "master" site, although the "default" site is used as fallback when a HTTP request matches no specific site (the normal case for non-multi-site setups). Except for that, all sites have the same rank and are unaware of each other. Each site uses the same core code and also the same sites/all/modules and sites/all/themes, while it may also add its own sites/sitedirectory/modules and sites/sitedirectory/themes. If the same module or theme is in present both locations, the site-specific location takes precedence, so you can have diverging versions of modules or themes between sites.
  • To add another site (or convert your single-site setup to a multi-site setup), simply create a new database for it, add sites/sitedirectory, copy sites/sitedirectory/default.settings.php to sites/sitedirectory/settings.php and visit the new site's URL in the browser. The usual Drupal installation procedure will be offered.
  • The files folder is usually placed under the site-specific folder, i.e. separate for each site (if you want it shared, you should also take care to share the files database table and possibly others).
  • Because the databases are separate, each site can have a different subset of all the available modules/themes enabled.
  • Because the databases are separate, you have to run update.php separately for each site when upgrading Drupal core or contributed modules.
  • Because the Drupal core is shared, you may run into dependency problems if at least one site requires a different version of Drupal core than the others.
  • Because the web server user and file permissions are shared, the multi-site configuration is potentially insecure: any site administrator who can run PHP code may access files (and, by peeking into settings.php, also gain full access to the database) of any site.

No comments:

Post a Comment