How to Setup Drupal for Multiple Sites
For Drupalers, one of the most attractive features of Drupal is its capability to install one single Drupal instance to serve for multi web sites (domains or subdomains). But, the pain point is that the installation guide from Drupal office site is not clear enough, or even confuse users. In below, we will guide you set it up step by step: Before we start, you should have successfully install one Drupal instance and your Drupal hosting allow you to create multiple sub domains or host more than one domains. Here, we will focus on how to add another domain to the existing Drupal instance.
- Create a new database and database users for the second domain (lets call it as "domain2.com")
- Grant full privileges to the database to the user created in the step 1)
- 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.
- 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)
- 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".
- Delete directory "/home/username/public_html/domain2"
- Create a symlink to the main site as "/home/username/public_html/domain2", the same as what in above. If you don't have Shell Access to your server, you could do it via php
- 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.