About Drupal multisite installations
Drupal can run multiple separate websites from a single codebase. The individual websites share code (the Drupal core, modules, and themes), but each website has its own database so they do not share content, configuration, settings, or displayed themes.
This configuration can be very helpful for global website management tasks, such as website upgrades, since you only have to upgrade one codebase. However, having multiple websites running from the same codebase can multiply problems, such as security issues across your websites.
To create a Drupal multisite, complete the following steps:
Sign in to Acquia, select your site, and open the Databases page at Cloud > Databases. Create a database for your new website.
The next step depends on which version of Drupal you are using. Drupal 6 requires a subdirectory in your
[docroot]/sitesdirectory that is named the same as the site's URL. For example, for a site with the URL
www.example.com, you'd need a directory at
[docroot]/sites/www.example.com. Drupal 7 allows you to use either the Drupal 6 approach, or unique directory names that are mapped to the URL in the
For Drupal 7:
- Create a new subdirectory in the
[docroot]/sitesdirectory with a name that will help you identify the site, for example,
- Go to your
[docroot]/sites/directory, and copy the
sites.phpin that directory.
sites.phpto include an entry for each of your sites, mapping the site directory to the URL. For example, for a site with the URL
emea.example.comand the site directory
[docroot]/sites/europe, add this line:
$sites['emea.example.com'] = 'europe';
For more information, see Using sites.php to specify an alternate settings.php file.
For Drupal 6:
Create a new subdirectory in
/sitesbased on your new website's URL, for example
For both Drupal 7 and Drupal 6, Drupal finds the correct site configuration directory by iteratively broadening matching URLs to domain names. For example, given the domain
test.foobar.baz.example.com, Drupal will check successively the following directories. For the site configuration directory, it uses the first one that exists and contains a file named
- Create a new subdirectory in the
/sites/default/default.settings.phpfile into your new website's subdirectory, and then rename it to
Go to the Cloud > Databases page, and click Connect to database to display the "require" statement for your website.
Copy the require statement to the clipboard.
settings.phpfile in the new website's subdirectory, and then paste your website's "require" statement to the end of the file.
Commit the changes to the new website's
settings.phpfile (and, if applicable,
sites.phpfile) to Acquia Cloud using the method based on your code repository:
In your browser address bar, enter
[site_URL]is the URL of the new website), and then press Enter. Continue with the standard Drupal installation procedure.
If you run a Drupal multisite on Acquia Cloud, you can add
settings.php files to as many
[docroot]/sites subdirectories as you need. Any domains for which you do not create a subdirectory will fall back to the
[docroot]/sites/default/settings.php file and load that website.
If you have a Drupal installation for a domain name (for example,
example.com) and you would like to add another site that will be located in a subdirectory of the same domain (for example,
example.com/subsite), the multisite configuration process is somewhat different.
- Ensure that you have
example.comdefined on your Acquia Cloud Domains page. There's no need to add additional domains that have the subdirectory appended.
- Add a new database for your multisite, if you haven't already done so. See Managing your databases for more information.
- Add a multisite subdirectory to the
/sitesdirectory, as described in step 2 in the preceding procedure. In our example, the multisite directory would be named something like
- On your Cloud > Databases page, click the Configure settings.php button for the Acquia Cloud require statement for the new database. On your server, you should copy the default
settings.phpfile from the
/sites/defaultdirectory and add the Acquia Cloud require statement.
Create a symlink in your docroot, linking the subdirectory name up one level, to the docroot. For our example, create the symlink by executing the following from the command line while in the
ln -s ../docroot subsite
- Add and commit the symlink and your multisite directory to your code repository.
Once the changes have been propagated to the servers, you'll be able to access your site at
example.com/subsite. If you need to import a database, you should do that as well, or visit
example.com/subsite/install.php to install a new Drupal site.
Sharing database tables across a Drupal multisite
You can also configure your installation to share database tables (such as the users, sessions, and profiles tables) across multiple websites. The procedure depends on your installed version of Drupal:
Maintaining cross-domain sessions with the $cookie_domain variable
If you have a Drupal multisite configuration where the additional sites are subdomains of the main domain (for example,
multisite.example.com), you may want to keep the user session active when the user moves between the sites. All that's needed is to add the following line to
settings.php, along with the shared database code:
$cookie_domain = '.example.com';
With this setting, you share the user tables between the sites and when a user logs into
www.example.com, they are logged into
multisite.example.com and vice versa.
This only works if each of the domains is on the same Acquia Cloud server and has the same second-level and top-level domain name. (For example,
multisite.example.com works, if both are on the same server, but
myothersite.example2.com will not.) Otherwise, browser security policies will invalidate the session cookie.