Acquia Copilot is a conversational AI connected into our product documentation and knowledge base. Ask Copilot about product features, technical details, troubleshooting and how to get started with Acquia products.
Drupal can run multiple separate websites from a single codebase. In a Drupal multisite architecture, 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.
Note
By default, new sites in multisite or Site Factory applications got unique hash salt starting from July 9, 2020. Create a Support ticket to enable hash salt for the sites that were created before July 9, 2020.
A multisite configuration can help you with global website management tasks, such as website upgrades, since you must only upgrade one codebase. Running multiple websites from the same codebase can multiply problems, such as security issues, across all your websites. For a more robust solution, consider Site Factory.
Common use cases for a Drupal multisite include:
Build a new site through a new installation process.
Copy a local site to Cloud Platform. In this case, Acquia recommends that you clear your Drupal cache if you have imported a database.
Create an additional domain for the new site. For more information, visit Managing domains.
Drupal uses the selection rules based on the multisite aliasing file sites/sites.php, which must be present to map multiple domains to specific directories. Drupal loads the optional settings in this file. The aliases in the array $sites overrides the default directory rules. For more information about configuring this file, visit default.settings.php.
Set the DNS for that domain with your authoritative DNS provider to point to the environment IP address with an A record. For more information, visit Configuring DNS records for your application.
Configure your aliases based on the sites/example.sites.php file.
In your local code repository, go to your [docroot]/sites/ directory, and copy the /sites/example.sites.php file to sites.php in that directory.
Edit sites.php to include an entry for each of your websites, mapping the website directory to the URL. For example, for a website with the URL emea.example.com and the website directory [docroot]/sites/europe, add the following line:
Create a new folder in [docroot]/sites/ with the database name that you created earlier.
Copy the /sites/default/default.settings.php file to your new website’s subdirectory, and rename it to settings.php.
In the Cloud Platform user interface, go to the Databases page, click PHP to display the include statement (also called the require statement) for your website, and copy that statement to the clipboard..
Edit the settings.php file in the new website’s subdirectory, and paste your website’s include statement to the end of the file.
If there are any unique modules or themes for the new site, create a /docroot/sites/<new-site>/modules or /docroot/sites/<new-site>/themes folder and add the code. Typically, you must put details about only custom modules that do not exist in any other site in these folders. Other modules or themes must be in:
/docroot/sites/all/modules or /sites/all/themes folder for Drupal 7
/docroot/modules or /docroot/themes for current Drupal version
Commit the changes to the new website’s settings.php file (and, if applicable, sites.php file) to Cloud Platform:
In the following Git commit, the -a option commits all the changes you made to the workspace. To commit only a specific file or directory, replace -a with the name of the folder or directory.
git commit -a -m "Added settings.php [and sites.php] for new website."
The commit command in Git only commits your changes to your local clone of the repository. To push those changes up to your Cloud Platform website for deployment, use the gitpush command to push the changes to the appropriate branch. For example, when deploying from a branch named master, use the following command:
git push origin master
Some Drupal distributions may have a .gitignore file as in the following example:
# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
Delete this line if it is present, because it prevents you from committing your website’s settings.php file. As an alternative, use the gitadd-fsettings.php command to force the code commit.
In your browser address bar, enter [site_URL]/install.php (where [site_URL] is the URL of the new website), and press Enter. Continue with the standard Drupal installation procedure.
Note
If you run a Drupal multisite on Cloud Platform, 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 fall back to the [docroot]/sites/default/settings.php file and load the default website.
Creating a multisite in a subdirectory of a domain
If you have a Drupal installation for a domain name (for example, example.com) and you would like to create another website in a subdirectory of the same domain (for example, example.com/subsite), the multisite configuration process is somewhat different.
Ensure you have defined example.com on your Cloud Platform Domains page. You do not need to add domains with the subdirectory appended.
Add a new database for your multisite, if you have not already done so. For more information, visit Working with databases.
Add a multisite subdirectory to the /sites directory, as described in step 3 in the preceding procedure. In our example, you would name the multisite directory something like /sites/example.com.subsite.
On the Databases page, click PHP for the Cloud Platform require statement for the new database. On your infrastructure, copy the default settings.php file from the /sites/default directory and add the Cloud Platform 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 /docroot directory:
ln -s ../docroot subsite
Add and commit the symlink and your multisite directory to your code repository.
After the changes propagate to the infrastructure, you can access your website at example.com/subsite. If you must import a database, do that as well, or visit example.com/subsite/install.php to install a new Drupal website.
Drupal can run multiple separate websites from a single codebase. In a Drupal multisite architecture, 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.
Note
By default, new sites in multisite or Site Factory applications got unique hash salt starting from July 9, 2020. Create a Support ticket to enable hash salt for the sites that were created before July 9, 2020.
A multisite configuration can help you with global website management tasks, such as website upgrades, since you must only upgrade one codebase. Running multiple websites from the same codebase can multiply problems, such as security issues, across all your websites. For a more robust solution, consider Site Factory.
Common use cases for a Drupal multisite include:
Build a new site through a new installation process.
Copy a local site to Cloud Platform. In this case, Acquia recommends that you clear your Drupal cache if you have imported a database.
Create an additional domain for the new site. For more information, visit Managing domains.
Drupal uses the selection rules based on the multisite aliasing file sites/sites.php, which must be present to map multiple domains to specific directories. Drupal loads the optional settings in this file. The aliases in the array $sites overrides the default directory rules. For more information about configuring this file, visit default.settings.php.
Set the DNS for that domain with your authoritative DNS provider to point to the environment IP address with an A record. For more information, visit Configuring DNS records for your application.
Configure your aliases based on the sites/example.sites.php file.
In your local code repository, go to your [docroot]/sites/ directory, and copy the /sites/example.sites.php file to sites.php in that directory.
Edit sites.php to include an entry for each of your websites, mapping the website directory to the URL. For example, for a website with the URL emea.example.com and the website directory [docroot]/sites/europe, add the following line:
Create a new folder in [docroot]/sites/ with the database name that you created earlier.
Copy the /sites/default/default.settings.php file to your new website’s subdirectory, and rename it to settings.php.
In the Cloud Platform user interface, go to the Databases page, click PHP to display the include statement (also called the require statement) for your website, and copy that statement to the clipboard..
Edit the settings.php file in the new website’s subdirectory, and paste your website’s include statement to the end of the file.
If there are any unique modules or themes for the new site, create a /docroot/sites/<new-site>/modules or /docroot/sites/<new-site>/themes folder and add the code. Typically, you must put details about only custom modules that do not exist in any other site in these folders. Other modules or themes must be in:
/docroot/sites/all/modules or /sites/all/themes folder for Drupal 7
/docroot/modules or /docroot/themes for current Drupal version
Commit the changes to the new website’s settings.php file (and, if applicable, sites.php file) to Cloud Platform:
In the following Git commit, the -a option commits all the changes you made to the workspace. To commit only a specific file or directory, replace -a with the name of the folder or directory.
git commit -a -m "Added settings.php [and sites.php] for new website."
The commit command in Git only commits your changes to your local clone of the repository. To push those changes up to your Cloud Platform website for deployment, use the gitpush command to push the changes to the appropriate branch. For example, when deploying from a branch named master, use the following command:
git push origin master
Some Drupal distributions may have a .gitignore file as in the following example:
# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
Delete this line if it is present, because it prevents you from committing your website’s settings.php file. As an alternative, use the gitadd-fsettings.php command to force the code commit.
In your browser address bar, enter [site_URL]/install.php (where [site_URL] is the URL of the new website), and press Enter. Continue with the standard Drupal installation procedure.
Note
If you run a Drupal multisite on Cloud Platform, 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 fall back to the [docroot]/sites/default/settings.php file and load the default website.
Creating a multisite in a subdirectory of a domain
If you have a Drupal installation for a domain name (for example, example.com) and you would like to create another website in a subdirectory of the same domain (for example, example.com/subsite), the multisite configuration process is somewhat different.
Ensure you have defined example.com on your Cloud Platform Domains page. You do not need to add domains with the subdirectory appended.
Add a new database for your multisite, if you have not already done so. For more information, visit Working with databases.
Add a multisite subdirectory to the /sites directory, as described in step 3 in the preceding procedure. In our example, you would name the multisite directory something like /sites/example.com.subsite.
On the Databases page, click PHP for the Cloud Platform require statement for the new database. On your infrastructure, copy the default settings.php file from the /sites/default directory and add the Cloud Platform 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 /docroot directory:
ln -s ../docroot subsite
Add and commit the symlink and your multisite directory to your code repository.
After the changes propagate to the infrastructure, you can access your website at example.com/subsite. If you must import a database, do that as well, or visit example.com/subsite/install.php to install a new Drupal website.