Share what you know with millions of people

Focus is the best place to turn what you know into remarkable content
×
0

A to Z of Drupal Multi-site Implementation

Introduction

 Today I’m going to introduce you how you can set up Drupal multi-site configuration in your windows machine with local host. I’m telling you all these facts based how I have set it up in my PC. It worked great for me with Windows XP, Apache 2.2, Drupal 6.x

 

What is multi-site?

 One Drupal core installation and multiple instances can be run from that for different domains or sub-domains.

 

What is multi site advantage?

 There is no separate installation needed every time we create a new Drupal site. Here common modules can be shared and custom modules can be protected.

Analysis

Before starting with this you must have the following ready.

  1. Apache web server (HTTP server)
  2. PHP configured to run with Apache server
  3. MySQL server.
  4. Normal Drupal 6.x installation.

 In order to install multi site you must have 2 local domains set up in your windows machine. In order to set up local domains, you have to do 2 different configurations

  1. windows host
  2. apache virtual host

 

Windows host configuration

             Go to C:\WINDOWS\system32\drivers\etc\hosts

Open hosts file in notepad.

  1. Add the following lines exactly as it is after the localhost (127.0.0.1   localhost

) settings

        127.0.0.1   drupalsite1

        127.0.0.1   drupalsite2

 Save the file and close.

 

Apache virtual host configurations

Assuming your Drupal installation has a folder name drupal and the Drupal installation directory will be looking like D:\xampp\htdocs\drupal

 

Open D:\xampp\apache\conf\httpd.conf

 

Add the following lines after </VirtualHost>

 

<VirtualHost *:80>

    ServerName drupalsite1

    DocumentRoot "D:/xampp/htdocs/drupal"

    ServerAdmin postmaster@drupalsite1

            ServerAlias tcs.saas wipro.saas demo.saas hello.saas

 

            <Directory "D:/xampp/htdocs/drupalsite1">

                        Options Indexes FollowSymLinks Includes ExecCGI

                        AllowOverride All

                        Order allow,deny

                        Allow from all

            </Directory>

 </VirtualHost>

 

<VirtualHost *:80>

    ServerName drupalsite2

    DocumentRoot "D:/xampp/htdocs/drupal"

    ServerAdmin postmaster@drupalsite1

            ServerAlias tcs.saas wipro.saas demo.saas hello.saas

             <Directory "D:/xampp/htdocs/drupalsite2">

                        Options Indexes FollowSymLinks Includes ExecCGI

                        AllowOverride All

                        Order allow,deny

                        Allow from all

            </Directory>

 </VirtualHost>

 

Note: If your default virtual host has all configurations other than the above, then you can move all that settings outside of virtual host and put all that after new virtual hosts. So, all virtual hosts will share those common settings.

In both virtual host set up DocumentRoot is same as your Drupal installation folder ("D:/xampp/htdocs/drupal")

Save the configuration file. Restart Apache server

 

Drupal Configuration

Now let’s configure Drupal for multi-sites.

 

After configuration we will have Drupal sites such as

 

http://drupalsite1 and

http://drupalsite2

 

Open drupal installation folder (D:/xampp/htdocs/drupal)

Navigate to sites. Here in default installation you will find two folders

 

default and all

Duplicate default folder 2 times and rename each with names such as drupalsite1 and drupalsite2

 Now you have total 4 folders such as default, all, drupalsite1 and drupalsite2

Next, duplicate drupal database and give names such as drupal_site1 and drupal_site2. In order to duplicate, you have to export and import Drupal database tables in two different databases (drupal_site1 and drupal_site2).

Now you have to configure the new site settings files.

Open D:\xampp\htdocs\drupal\sites\drupalsite1\settings.php

Edit the database settings for new database drupal_site1. Save it and close.

Similarly open drupalsite2 folder and edit database settings for drupal_site2.

 Now both sites http://drupalsite1 and http://drupalsite2 are ready. But it will look identical.

 

Site specific Settings

In order to configure site name and themes for http://drupalsite1 you have to open the admin panel for that site http://drupalsite1 by log in using your Drupal. After login, go to http://drupalsite1/admin/settings/site-information. Do your changes and save it. Go to home page and see the changes. Awesome!

Similar way you can configure drupalsite2 by log in from http://drupalsite2

 

Changing theme

Open D:\xampp\htdocs\drupal\sites\drupalsite1

Create folders such as themes and modules as in regular Drupal. Copy theme to theme folder and go to theme configurations, http://drupalsite1/admin/build/themes

 Enable your new theme for drupalsite1.  Similarly you can copy a different theme to drupalsite2 themes folder and enable it. Now your 2 sites have different theme. Similarly you can add modules to module folder in both sites under module folder that we have created.

 This way drupal core will be common for all sites but settings, theme and modules can be different. Drupal multi-sites share drupal core, common themes (D:\xampp\htdocs\drupal\themes), common modules (D:\xampp\htdocs\drupal\modules) etc. But custom themes and modules from local folders (D:\xampp\htdocs\drupal\sites\drupalsite1 or drupalsite2) can’t be shared.

 Now you have one Drupal core and there different sites. Which one is the 3rd site?

Also you can create more sites in similar way.

Conclusion

With minimal effort and system resources, multiple web sites can be hosted with single installation of Drupal. It will help to maintain a single application core and hence, it will avoid multiple maintenance and upgrades etc. Apache and host configurations and custom site configurations will help to manage multiples sites easily.

Disclosures and References
0
ajay
Posted on Dec. 27, 2010

It was very nice.I tried it and got it.

0
JD
Posted on Jan. 14, 2011

Great Solution....
I need some more basic docs. Please send if possible.
Thanks

0
Najeem Illyas
Enterprise Architect, Ed Ventures E-Learning Pvt Ltd, Hyderabad
Posted on Jan. 14, 2011
  • Recommended by:

Hi JD,

Can you please specific about what basic topics you need detailed information?

Regards,
Najeem

0
pankaj singh
Posted on Jan. 17, 2011

Hi ,

it is good concept to learn about drupal so could you please provide some more information abt drupal

0
Nancy Wichmann
Drupal Web Developer, MacCormick Software
Posted on March 6, 2011
  • Recommended by:

I find this sufficient:

ServerName site1
DocumentRoot "C:/wamp/www/drupal6"


Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from 127.0.0.1

I also do not (generally) put themes or modules in the site folder. Rather I add them to sites/all/... This way, I don't accidentally get different versions between the sites.

I used to copy the database (in D5), but I now find it safer to just do a separate install.php on each site. If you are going to use the copy methid, then I would suggest doing some basic set up first, such as adding user/2 (usually myself under my own name), an admin role, error reporting, file settings, etc. Then copying may save you a few minutes of time.

For those who need more basic info, try http://drupal.org/documentation/customization/tutorials/beginners-cookbook

0
Najeem Illyas
Enterprise Architect, Ed Ventures E-Learning Pvt Ltd, Hyderabad
  • Recommended by:

Hello Nancy,

"I also do not (generally) put themes or modules in the site folder. Rather I add them to sites/all/... This way, I don't accidentally get different versions between the sites."

You can place your themes or modules in sites/all/ folder, but that will not help individual site owners to hide their themes and modules. In this case if you open the admin url of any site, you will find all modules and themes. But in my case, I want to show only the relevant themes or modules to specific domain admin.

Database install can be done in various ways. You can make duplicates and edit them manually or install from each domain etc.

Thanks for the addendum

Regards,
Najeem

Answer This Question