For Multiple Websites With One Drupal Installation

With just one installation of Drupal, we can run multiple websites like:-
(A) with completely different domain names.
Eg. www.my_domain.com, www.mum_domain.com and www.dad_domain.com.
Of course the above 3 domain names must be validly registered and nameservers point to the same server say, ns1.same_server.com
(B) subdomains
eg. chinese.my_domain.com, english.my_domain.com
Subdomains like above are not registered names. Read "How To Create Subdomain in cPanel"

In this tutorial we'll illustrate using (A) above, i.e completely different domain names.
Our original website is www.my_domain.com (which you will notice in the images later is actually more_nursing.com). I'll addon another domain named more_singapore.com. So it's one Drupal installation running 2 websites.

For this illustration, the addon domain more_singapore.com actually shows the same content as my_domain.com because it is using the same database as my_domain.com. In practice we need to create a different database and database username for the second website more_singapore.com; upon installation, we are required to enter this information. So example:-
www.my_domain.com // website about company // database / username say db_company
www.more_singapore.com // website on travel // database/username say data_travel
- all in the same one cPanel account http://www.my_domain.com/cpanel
- one single Drupal installation
- running two different websites my_domain.com and more_singapore.com
- 2 or more databases corresponding to each website and configured via each website's settings.php file.






Configure Our Drupal To Include Another Website

Go to http://www.my_domain.com/cpanel

Login username and password.

We need to just create another folder named as the same addon domain name(s) under /public_html/sites/[HERE] and copy the /sites/default/settings.php file to each new folder here like this:-
/sites/dad_domain.com/settings.php
/sites/mum_domain.com/settings.php

For each new website, create a new database (use a different mnemonic to indicate different website), username and password. For our illustration, the addon domain more_singapore.com is using the same database as my_domain.com. Hence we just copy the same settings.php at /sites/my_domain.com/settings.php. We skip creating new database.

Select > File Manager > Go > sites > New Folder > [New Folder Name] more_singapore.com > Create New Folder [note: new folder created /public_html/sites/more_singapore.com]
> [continued] > my_domain.com > settings.php > Copy > [copy to] /public_html/sites/more_singapore.com > Copy File(s) > Up One Level > more_singapore.com > settings.php [note: running same database as my_domain.com, so content will be same]

Important: File permission for settings.php should be 444. After we install Drupal first time, the system automatically changes this to 444. If we need to edit to manually enter database information, we change this file to 644. Please change back to 444 after amendment.

picture

That's it. The Drupal setting for the second website is done!





In cPanel, we need:-
1) create Addon Domain for more_singapore.com
2) rename (or delete) /public_html/more_singapore.com (auto created by 1 above)
3) create a php file in /public_html/[HERE] to 'symlink' i.e to point system to look for Drupal files in public_html/[HERE] (and not public_html/more_singapore.com/[HERE]). We can call this file anyname. We give it my_symlink.php
4) Execute (run) this http://www.my_domain.com/my_symlink.php file

That's it. When you call http://www.more_singapore.com, it will look for all Drupal files here i.e. /public_html/[HERE] including /public_html/sites/more_singapore.com/settings.php






cPanel - Addon One Domain For Our Website more_singapore.com

Go to http://www.my_domain.com/cpanel

Login username and password.

Select > Addon Domains

picture

(continued)> [New Domain Name] more_singapore.com > [the rest of textboxes autofilled] > [Subdomain / Ftp Username] more_singapore > [Document Root] /public_html/more_singapore.com > [Password] my_passwd_xxx > [Password (Again)] my_passwd_xxx > Add Domain!

Select > Home > Add Domains > [scroll down]

picture






cPanel - Rename Folder (Auto Generated By System) And Create/Execute 'Symlink' Php File

Select > File Manager > Go > more_singapore.com (this folder auto-created by system) > Rename > [type] old_more_singapore.com > Rename File (folder renamed)

(continue) > New File > [New File Name] my_symlink.php > [Select File Type] Text Document > [New file will be created in] /public_html > Create New File

picture

(continue) > my_symlink.php > Edit > [enter]

<?php
symlink(".", "more_singapore.com");
print "Well Done";
?> 

picture

> Save Changes > X (close window)

Open a new browser.

Select > Internet Explorer

Go to http://www.my_domain.com.

Amend in URL box to http://www.my_domain.com/my_symlink.php (this is to execute the file to create the symlink). Press Enter. You should get below.

picture

(earlier opened window) > [right frame] > public_html > Change Permissions > 755 > Change Permissions > X

picture

[Observe: The public_html/more_singapore.com is again created when we run the symlink.php file. Click this more_singapore.com folder and we see all the Drupal files because it is pointing to public_html]

Also change permissions to the my_symlink.php file to 'switch it off'.
Select > public_html > my_symlink.php > Change Permissions > 600 > Change Permissions > X

Logout

That's it. Go to the second website http://www.more_singapore.com

picture