Sunday, March 29, 2009

Run multiple sites from the same code base (multi-site)

Run multiple sites from the same code base (multi-site)
Drupal 6.x · No known problemsLast modified: January 13, 2009 - 16:46
If you are running more than one Drupal site, you can simplify management and upgrading of your sites by using the multi-site feature. Multi site allows you to share a single Drupal installation (including contributed modules and themes) among several sites. This is particularly useful for managing the code since each upgrade only needs to be done once.

Each site would continue to have it's own database and its own configuration settings so each site would have entirely different content and you can still specify the theme, modules and other settings for each site.

To configure a new site
Create a new database for the site
Create a new subdirectory of the 'sites' directory.
Copy the settings.php file from the 'default' directory to the new directory.
Open the settings.php file in a text editor and specify the settings for the new site.
In your browser, navigate to the URL of the new site and continue with the standard Drupal installation procedure.
Domains and URLs
The new directory name is constructed from the site's URL. The configuration for could be in 'sites/'. Note that 'www.' is not required to access your site at - * is served from that directory unless a subdomain is also defined. You should also adjust .htaccess to redirect www to

You can also use sub domains and subdirectories for Drupal sites. For example,,, and can all be defined as independent Drupal sites using the following directory setup:


If you are installing on a non-standard port, the port number is treated as the deepest sub domain. For example: could be loaded from sites/ The port number will be removed according to the pattern above if no port-specific configuration is found, just like a real sub domain.

Each site configuration can have its own site-specific modules and themes in addition to those installed in the standard 'modules' and 'themes' directories. To use site-specific modules or themes, simply create a 'modules' or 'themes' directory within the site configuration directory. For example, if has a custom theme and a custom module that should not be accessible to other sites, the setup would look like this:


Document root
One area of frequent confusion is that in a Drupal multisite installation the webserver document root is the same for all sites. For example with the following three sites:, and there will be a single Drupal folder and all sites will be calling the same index.php file.

Some webhosts automatically create a folder (i.e. when creating a new domain. In this case it is necessary to create a symbolic link to the Drupal folder.

Installing a separate site in subfolders is accomplished by adding it with a dot after the domain name - the site3 example above. This also needs a symlink created from the document root to itself -- e.g. 'ln -s /var/www /var/www/site3'.

On many systems it is possible to create entries in a "hosts" file to create aliases for the localhost name for a local workstation. By creating aliases for localhost it is possible to create names such as and, both for the local computer.

No comments: