Multi-site installation with shared database (but not data)
Drupal allows you to run multiple sites using just one Drupal installation, which considerably simplifies keeping each site's code up-to-date (as you only need to update once for all sites, rather than once for each site). There are some useful instructions for installing a "multi-site" at Drupal.org, specifically Run multiple sites from the same code base (multi-site) and Create Multi-site for dummies, but the explanations for some of the steps are a bit unclear, especially if your additional site does not have its own domain or subdomain name and you want to use the same database but not share data.
So here are the steps for installing an additional site as a subdirectory of your main site, e.g., installing a site at http://www.example.com/secondsite using the same codebase and the same database (but not sharing data) as the site at http://www.example.com. (Adapted from the before mentioned web pages, with some additions.)
- Create a new subdirectory in the 'sites' directory, e.g. '.../sites/www.example.com.secondsite'
- Copy the settings.php file from the 'sites/default' directory to the new directory, e.g., copy .../sites/default/settings.php to .../sites/www.example.com.secondsite/settings.php
- Edit the new settings.php file (e.g., edit .../sites/www.example.com.secondsite/settings.php):
- Uncomment the base URL and change it to the new site's URL. E.g., change it from:
# $base_url = 'http://www.example.com';
to
$base_url = 'http://www.example.com/secondsite'; - Change the database prefix parameters so the prefix is different from the main site's prefix (if any). E.g., change it from:
$db_prefix = '';(or$db_prefix = 'main_';, etc.)
to
$db_prefix = 'secondsite_'; - (Leave the db_url setting unchanged -- these instructions are for sharing the database as well as the codebase)
- Uncomment the base URL and change it to the new site's URL. E.g., change it from:
- Create a symbolic link from /path/to/main/drupal/dir/secondsite to /path/to/main/drupal/dir (using the command line):
ln -s /path/to/main/drupal/dir /path/to/main/drupal/dir/secondsite - In your browser, go to the install.php page of your new site, e.g., http://www.example.com/secondsite/install.php
- Complete installation as usual through the Drupal interface.
The new site will have access to all the modules and themes available to the main site, but you can enable or disable them independently. (If you want to install a module or theme only into the sub-site, instead of putting it in .../sites/all/modules or .../sites/all/themes, put it into ...sites/www.example.com.secondsite/modules or .../sites/www.example.com.secondsite/modules.)
- Login to post comments