Thursday, 29 November 2012

Drupal - Setup Multi Site Approach


To Implement Multi site Approach  in Drupal, we have to follow below steps

Step1:

Set up Hosts file:
  1. We need to add the two sites names in hosts file, that we need to use for Multi Site Approach.
  2. This file will be located in c:\\windows\system32\drivers\etc\hosts
  3. Add the below listed values in end of the hosts file
  4. 127.0.0.1    site1.com
    127.0.0.1    site2.com

Step2:

Setup httpd.conf file:
  1. Create virtual hosts in httpd.conf file for both the sites.
  2. That file is located at Xampp\apache\conf\httpd.conf
  3. add virtual hosts at the end of the file.

    <VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs/singledrupalinstancefolder"
    ServerName site1.com
    ServerAlias *.site1.com
    <Directory "D:/xampp/htdocs/singledrupalinstancefolder">
    Allow from all
    Options +Includes +Indexes +FollowSymLinks
    AllowOverride all
    </Directory>
    </VirtualHost>



    <VirtualHost *:80>
    DocumentRoot "D:/xampp/htdocs/singledrupalinstancefolder"
    ServerName site2.com
    ServerAlias *.site2.com
    <Directory "D:/xampp/htdocs/singledrupalinstancefolder">
    Allow from all
    Options +Includes +Indexes +FollowSymLinks
    AllowOverride all
    </Directory>
    </VirtualHost>

Step3:

Restart the Apache server after saving the httpd.conf file:

Step4:

 Create Multiple sites in your project folder:
  1. in singledrupalinstancefolder>> sites >> site1.com
  2. in singledrupalinstancefolder>> sites >> site2.com
  3. copy the default.settings.php and place it in two sites folders.
  4. rename that file to settings.php in two sites folders.[If in case it is Drupal 6]
  5. then install the two sites by accessing http://site1.com in url and http://site2.com
  6. what ever the modules that we wish to create for site1 alone , place them in site1.com folder under modules
  7. what ever the modules that we wish to create for site2 alone, place them in site2.com folder under modules
  8. what ever the themes that we wish to create for site1 alone, place them in site1.com folder under themes
  9. what ever the themes that we wish to create for site2 alone, place them in site2.com folder under themes
  10. place common modules and themes in singledrupalinstancefolder\sites\all\modules and singledrupalinstancefolder\sites\all\themes folder
  11. We can use same database with prefix_ difference or We can use two different databases.
These are the main things that we need to do for multiple siteapproach

Note: In Drupal 7 you can point the two sites folder names in sites.php file

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.