Last updated March 4, 2012. Created on August 20, 2009.
Edited by jhr, chicagomom. Log in to edit this page.

Prerequisites

This guide assumes you have the following installed and running:

  • Microsoft's Internet Information Services web server 6 or 7
  • PhP 5.2 or higher with PDO dlls enabled.
  • The IIS FastCGI Module (IIS6 version here - in IIS7 it's an integrated module that needs to be enabled).
  • MySQL
  • If you want clean urls, you'll also need the URL Rewrite module (IIS7) or a third-party url-rewrite module set up at some point, though you can do this afterward.

Process

  1. Install a site. This will be the parent site, providing the code-base for all the child sites.

    IIS7: be sure your parent site has a web.config file (see this for more info). Child sites will use the settings in the parent site's web.config file. To override these settings, put a web.config file with just the settings you want to override in the child site's folder (eg sites/site2.com/).

  2. Create child site folders. Decide how you want people to navigate to your sub-site. In the parent site's /sites/ folder, create sub-folders for each new site you wish to install.
  • Example 1: parentsite.com/subsite/ - in parent /sites/ folder, create /sites/parentsite.com.subsite
  • Example 2: subsite.parentsite.com - in parent /sites/ folder, create /sites/subsite.parentsite.com
  • Example 3: subsite.com - in parent /sites/ folder, create /sites/subsite.com
  • Copy the files & private subfolders. Go into the parent site's sites/default folder, and copy the /files and /private folders. Navigate to each new child site's folder (eg sites/parentsite.com/subsite/) and paste them.
  • Create child site settings.php file(s). Into each child site folder copy the parent's /sites/default/settings.php. Make each settings.php writable to IIS_WPG (IIS6) or IIS_IUSRS(IIS7).
  • Create IIS Site Mapping or Virtual Directory, depending on how you set up your site structure.
  • IIS7 - Start the IIS Manager.

    • Example 1: parentsite.com/subsite/ - Right-click on parentsite.com | Add virtual directory. Alias: [new site name, eg subsite]. Physical path: [parent site's physical path]. Click OK.
    • Example 2: subsite.parentsite.com - Right-click on Sites | Add web site. Site name: [new site name, eg site2]. Click to select the application pool, and select the parent site. Physical path: enter the parent site's physical path. Host name: [new site url, eg site2.localhost]. Click OK.
    • Example 3: subsite.com - add a web site as example 2, calling the host name subsite.com.
  • Set up the database(s).

    Multiple databases - If you want each site to have it's own database, create them now.

    For each child site, change settings.php to include each site's database name, username, and password:

       $databases['default']['default'] = array(<br />
      'driver' => 'mysql',<br />
      'database' => 'databasename',<br />
      'username' => 'username',<br />
      'password' => 'password',<br />
      'host' => 'localhost',<br />
      );
     

    Single database - See this tutorial.

  • Run the setup script for each site, eg http://site2.localhost/install.php.
  • Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

    Comments

    dAv3’s picture

    Has anyone got this working?

    I have been trying for the last week to get multisite set up with
    - Drupal7,
    - IIS 7.5,
    - SQLSRV,
    - on WinServer 2008 r2.

    Step 1 says - Install a site. This will be the parent site, providing the code-base for all the child sites.

    Does this mean install a site at the base directory as in drupal7/ and then the two you actually want under drupal7/sites/...
    so you'll have three or just move the dupal files to your base - drupal7/ and then proceed with installing the 2 site you want under base-dir/sites/... ?

    I'm trying to set two sites(www.site-one.com & www.site2.com) to use the same codebase, with seperate databases. I've set up the following directories, with the appropriate contents and permissions in each (/files, /themes, /modules, settings.php).
    drupal7/sites/site-one.com
    drupal7/sites/site2.com

    how can i actually browse to these two subsites and begin the install? I think my IIS mapping may be off because i try to navigate to http://localhost/site-one.com and all i get is a 404 error?

    I can get a single site up without any problems so i know all the components are working.

    Can anyone help with this, its causing pre-mature baldness??

    chicagomom’s picture

    Assuming site-one.com is your first site, and is in the web root, the directory for that site would be drpal7/sites/default, and you would navigate to it by http://localhost. The second would be drupal7/sites/site2.com/, into which you would put web.config and settings.php files. Use the default web.config that comes with d7. Put your site2's database info in this settings.php file.

    For localhost to recognize the second site via URL appropriately you would need to edit the HOSTS file thusly:

    127.0.0.1 site2.com

    On an external webserver this would be handled by DNS pointing the appropriate domain names at that server's IP. Since you're doing localhost you have to fake it by editing your HOSTS file.

    Then if you navigate to http://site2.com/setup.php, the local web server should recognize it and begin the setup process for you.

    Hope that's helpful.

    dAv3’s picture

    I changed my directory structure so that my drupal install is located directly under the web root:
    - [web root]/drupal-files
    instead of:
    - [web root]/drupal7/drupal-files

    Now i have:
    [web root]/sites/site1.com
    [web root]/sites/site2.com

    - In each i put a web.config file and different settings.php files,
    - I edited my hosts file - 127.0.0.1____site1.com & 127.0.0.1____site2.com,
    - Cleared my dns cache (probably not necessary)
    - and browsed to each site1.com/install.php and site2.com/install.php

    And it's done, two sites up and running, without needing to set up a default site and without having to play around with iis bindings.

    BUT the thing is I don't want drupal files all over my [web root], I'd prefer to put them somewhere else or install in a subdirectory like:
    [web root]/drupal7/drupal-files, thats where I was running in to trouble.

    How can i set it up so that my drupal install will be hosted in a sub-directory of the web root?
    Something like:

    [web root]/drupal7/drupal-files

    [web root]/drupal7/sites/site1.com
    [web root]/drupal7/sites/site2.com

    Thanks for your help

    dAv3’s picture

    Okay, so i finally got it working.

    To have a multi-site drupal installation in a subdirectory of the web root, in IIS I needed to bind the websites to the directory which drupal is installed eg [web root]/drupal7

    I have installed two websites side by side, under the one drupal codebase without having to setup a default site(any drawbacks to this?), which was the goal of my installation(to have two equal sites).

    So to recap I:

    - setup websites under [drupal dir]/sites/
    - make sure they have a standard web.config, and a settings.php file that is specific to each site (also /files, /themes and /modules folders for future use).
    - enter the sites in my hosts file to point to 127.0.0.1
    - create a website in IIS for each site, with the physical path pointing to the location of your drupal install
    - run the script for each site, eg http://site2.com/install.php
    - and it's running swimmingly

    I don't know where i went wrong, it's all in the original guide i just didn't see it!

    Thanks chicagomom for your efforts, deffinately put me on the right path and got it working for me.

    Cheers. :)

    dzigner’s picture

    Hi
    This is what I am trying to do, and cannot find how to do this. Maybe you can help me.
    My webhost has this configuration:

    1. windows server 2003
    2. iis7
    3. php 5.2.5
    4. MySQL 5.0.9

    My domain is www.des-us.com. I have installed drupal under a subfolder in document root and directed a subdomain to this install. So my files are under /dessites folder and the url I use is http://dessites.des-us.com. Now I want to create a subsite under sites/des-us.com, which should use the same codebase, but a different database. So my domain(http://www.des-us.com) should access the codebase at the subdomain http://dessites.des-us.com. I have configured the databases for both the sites.
    I cannot use .htaccess on my server, and I have no putty access to it, nor do I have access to the IIS manager. I cannot edit the host file. I have ftp access.
    How can I achieve this setup? Please let me know.
    thanks

    p.s: OK, so now I have got the http://www.des-us.com site running, but I cannot access http://dessites.des-us.com anymore. These are the steps I took:
    1. install drupal codebase on http://dessites.des-us.com with mysql db.
    2. create a folder des-us.com under /sites/. Setup a different mysql db.
    3. point the site des-us.com to /dessites as physical path.
    4. give hostname des-us.com, dessites.des-us.com the same IP address.

    Then I check http://dessites.des-us.com, and it accessed the database of des-us.com, and not the database I originally setup for the codebase. I could start the install at http://www.des-us.com, and it accessed its own database. After the install, at http://dessites.des-us.com, I get the same site as at http://www.des-us.com. Also, I have no admin tabbar even though I am signed in as an admin.
    Please help me.

    I have decided to just let this go, as I am not getting any help anywhere.
    thanks

    shantidev’s picture

    Hi,

    Thanks for the tutorial on drupal 7 multisite on IIS. I have installed drupal 7 on Windows 7 and using IIS as the webserver.

    I followed the instructions to install multisite. I am able to access the site successfully using localhost, i.e http://localhost:port/subsite

    However, when I am using the IP address (LAN IP address or my public IP address) http://[LAN IP/PUBLIC IP]:port/subsite, I am getting the default site instead of the multisite.

    This is confusing me. Please advise if I need to set specific entries in my sites.php to get it right.

    I want to be able to access my multisites from other machines on my LAN as well as remotely. I have taken care of the port forwarding in my router.

    Thanks
    Regards,
    Shantidev