Cheap Business Hosting HostMonster, #1 Linux Hosting, $4.95/month only, Unlimited Disk space, Unlimited Monthly Transfer, Best Low Cost Small Business Hosting
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.
- 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.
- 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 ANHosting, and work very well. Hopeful this will help you setup multi site with one Drupal installation.
Copyright:
|







