Drupal's multi-site feature allows multiple sites to run from the same core code, while having separate databases, configurations, and user files. Multi-site functionality removes the pain in managing multiple cores and multiple sets of modules, meaning that there is only one primary installation that needs to be updated and managed. It also reduces the amount of disk space that is required.
In this recipe, we will see how to prepare the secondary site's domain so that it points to the primary site's Drupal installation. We will then see how to activate and install the multi-site functionality on the primary site.
You will need the following:
An existing Drupal installation for your primary site
A domain name for your secondary site
The ability to update your secondary domain to point to the name server of your primary domain
You will need the ability to create an add-on domain for your primary site (we will see how to actually create the add-on domain in the recipe)
A blank database
1. Update your secondary domain's name server to be the same as the primary domain's name server.
2. On your primary server, log in to your server's admin panel and create a new add-on domain. Add the URL of the secondary domain as the new domain name.
3. Add a username and password. This is to enable you to provide specific FTP access to the secondary domain without providing FTP access for your primary domain. Set the document root to be the location on the server of your primary Drupal installation:
4. On your primary site create a new folder inside your sites directory which has the same name as your secondary site, for example,
/Drupal root/sites/secondary-site.com/
.5. Copy
default.settings.php
from the following folder:/Drupal root/default/
to the/Drupal root/sites/secondary-site.com/
folder.6. Rename the newly copied file to
settings.php
and set its permission to666:
7. Under
/Drupal root/sites/secondary-site.com/
, create a new folder calledfiles
and set the folder permission to777
.8. Go to your secondary site in your browser; you will see the standard installation screen.
9. Complete the installation wizard as described in the first recipe of this chapter (Installing Drupal). On the database settings page enter the login credentials of your newly created empty database.
10. After completing the installation, set the permissions of
Drupal root/sites/secondary-site.com/settings.php
to444
.
Updating the name server is usually done through the domain registrar. The name server you need to enter for the secondary domain will most likely be provided by your hosting provider for your primary domain in the welcome e-mail. You may need to wait some time for the DNS records to propagate before your domain name resolves to the newly appointed server.
Creating an add-on domain allows you to set up a third-party domain to point to your hosting directory without having to redirect the user. This means that the URL in the address bar of the user's browser will remain constant, even though they are accessing the directory of another site. The setup procedure for configuring an add-on domain may be different with different hosting providers and control panels, and this example references the cPanel management panel. If you find difficulty getting this to work, reference your hosting provider's documentation for add-on domains.