How to Setup Multi Sites with One Drupal Installation

Drupal is a very powerful open source content management system. And one of the most attractive features from Drupal is that it will allow you to install one single Drupal code base which can serve for multi web sites, each with its own individual configuration.

But unfortunately, the guide from Drupal office site on how to config this feature is not clear enough, and the beginner might be lost during it. In below, we will provide you with the step by step guide to set it up:

Before we start, you should have successfully install one Drupal instance, if you still haven't, please refer to How to Install Drupal to know more. Here, we will focus on how to add another domain to one Drupal installation.

  1. Create a new database and database users for the second domain (lets call it as "domain2.com")
  2. Grant full privileges to the database to the user created in the step 1)
  3. create a sub-directory in the "/sites" directory call "domain2.com", it will look like /sites/domain2.com/. Please don't include 'www' in the sub-directory.
  4. Copy the /sites/default/default.settings.php to the new directory /sites/domain2.com/settings.php (don't forget to remove the 'default.' from the file name)
  5. Setup the addon domain for "domain2.com" in your web hosting account. For a shared web hosting environment, domain2.com will point to a directory like "/home/username/public_html/domain2".
  6. Delete directory "/home/username/public_html/domain2"
  7. Create a symlink to the main site as "/home/username/public_html/domain2", the same as what in above.
  8. Launch the domain2 in browser, Drupal Installer will be launched, go through the installation process according to on-screen instructions. You will get new web site setup on the same Drupal code base.

Notes:

The reason we need to go through step 5 is to bind the domain2.com with your web hosting account so that your drupal instance can control the display for each site. But by default, the new domain will be binded with the directory "/home/username/public_html/domain2", and what we want is to have domain2.com point to the same folder of the first domain so that when we try to access domain2.com, Drupal will get the chance to control the display of ths site. This can be resolved by follow Step 6, and Step 7.

In step 6, we will remove the folder /home/username/public_html/domain2, there is no need to have this folder exist any more. But we need a symbolic links with the same name which will point to the directory of the first domain. The theory behinds this is that when web server try to access the resource /home/username/public_html/domain2 to launch domain2.com, after going through step 7), the resource is not a directory any more, it's a symbolic link refer to the main Drupal folder, and then Drupal get the control of the rest.

To create symbolic link will be very easy if you have the Shell access, you can run the below command in your Unix shell, but for most shared web hosting, you will not be provided with this access due to the security reason. That's fine, you can follow How to Create Symbolic Links (Symlink) Using PHP to finish this step.

Here is the command to create symbolic link in Shell:

    ln -s /home/username/public_html/  /home/username/public_html/domain2  

you will need to change the username according to your web hosting environement, and for "/home/username/public_html/", if your Drupal is installed in the root, then you can keep it, otherwise, you will need to change the directory to where Drupal is installed.

Above method has been practice in Bluehost, and work very well. Hopeful this will help you setup multi site with one Drupal installation.

Popular Hosting Reviews

Best Web Hosting Awards

Each web hosting solution is designed for some purposes, it could be from blog web hosting, family site hosting to ebusiness web site hosting. In webhostingclue.com, we give out the Best Web Hosting Awards to those which have been the best solutions for the given categories.

Best Linux Hosting Best Cheap Web Hosting Best WordPress Hosting
Best Windows Hosting Best Small Business Hosting Best Drupal Hosting
Best VPS Hosting Best Family Web Hosting Best Joomla Hosting
Best Dedicated Server Best Green Hosting

Know more about How We Select the Hosting Award Winners

DISCLOSURE

We are a professional review site to help people find best web hosting with lowest price. We receive compensation from the companies whose products we review. But we test each product thoroughly and give high marks to only the very best from hundreds of hosting products.