For Drupalers, one of the most important features of Drupal is its capability to setup multiple sites with one Drupal instance only. But, the pain point is that there is no clear installation guide available even from Drupal.org.
After trying the installation for many times, I summarize the steps I have followed in below, hopefully, it’s helpful for you. First of all, 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.
- First, prepare a new database and its users with full privileges for your another domain, (lets call it as “SiteB.com”)
- Create a sub-directory in the “/sites” directory call “siteb.com”, it will look like /sites/siteb.com/. Please exclude ‘www’ in the sub-directory.
- Copy file default.settings.php in “sites/default/” to the new directory “/sites/domain2.com/” as settings.php
- Create an addon domain (or vhosts) for “siteb.com” in your web server. If you use shared hosting, it might looks like “/home/username/public_html/siteb”.
- Remove directory “/home/username/public_html/siteb”
- Now, this is the critical step, you need to get siteb to link “home/username/public_html/siteb”, to the main site. It’s easy to do this via shell, however, if you don’t have this permission, you can follow this guide to create one via php script.
- Launch the siteb Drupal installer in browser, follow the steps in the screen, and then you will see you secondly Drupal is up. If you want, if you repeat step1-step6 to add third sites to the instance.
Above method has been practiced in GreenGeeks, and should work well in almost all the web hosting environment you could find from the market.