Warning message

Documentation is currently being migrated into the new system. Some pages might be temporarily missing, and some guides might appear empty. Thank you for your patience while we are improving Drupal.org documentation.

Multi-site on Windows - using IIS

Last updated on
August 30, 2016 - 13:47

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(
      'driver' => 'mysql',
      'database' => 'databasename',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
    );

    Single database - See this tutorial.

  • Run the setup script for each site, eg http://site2.localhost/install.php.