0

Multisite setup

Posted July 2nd, 2010 in by thomas

The goal is to have a single drupal core to handle multiple sites / instances

1. installation

install drupal as usual

2. directory structure

inside site/ create a directory for each of your site named yoursitename.tld

inside yoursitename.tld create

  • directories for the specific modules and themes (you can then split it in contrib/ and custom/) + files
  • copy settings.php and adapt db site’s specific values
  • put the modules used by every sites (cck, pathauto, devel, admin_menu, …) in site/all/modules

3. virtual host

  • DocumentRoot is the same for every sites : that’s where your installation sits (/var/www/drupal6 for example)
  • ServerName is the name of your site (!), drupal will use it to map the name of your site.tld with the site/ directory structure

4. pros

  • update core / shared modules only once
    => you can create a script to run cron for all sites
  • quick creation of new sites

5. cons

  • on core issues, all sites are down…
  • high load of the server
  • you have to manually run update.php on every site (it can take times when a site may be + – down)

more info on drupal’s website

6. sharing databases / tables

it’s possible to share data between sites.

example: if you want sitea and siteb using the same users, but with different content, you will have

  • 3 databases for the 2 sites, (1 for content sitea / siteb, 1 for shared tables)
  • shared tables (users, sessions,…) must be have the prefix of the shared database in settings.php / Database area ( shared_db. with . for sql join)
  • a default prefix (indicated only once) for other tables
  • $db_prefix = array( ‘default’ = ”, ‘users’ = ‘shared_db.’, ‘role’ = ‘shared_db.’, ‘sessions’ = ‘shared_db.’, );

  • to permit a same user login on sitea AND siteb, install single sign on module

note : it’s also possible to have only 1 databases with same prefixes for common table and different prefixes for the other ones (this time prefix without . ’cause we use the same db)

more info on drupal website

note : you can also take a look, at this video with interesting server settings

=> an other interresting module (not tested yet) : Domain

edit : I’ve test it on several projects and Domain module is awesome !! nice documentation, incredible functionalities , powerful hooks… a really must have module for multisite management !!

Leave a Reply