masthead image

Technology Blog

How To Setup A Drupal Multisite On Windows

Wednesday January 14 2009, 04:00 PM

A few people have requested me to write an article on setting up a Drupal multisite installation on Windows. Note that this discussion is adapted from a previous article I wrote which explained how to do this on shared hosting environments on cPanel.

Prerequisites

Some things to consider before I get started. I assume you have installed your entire WAMP stack (Windows, Apache, MySQL, and PHP) on a local development system and are ready to proceed installing Drupal. If you like more information on how to do this, read How To Setup A WAMP Development Environment. Although I do not have access to Windows 2003/Windows 2008 server, the instructions here should apply.

In summary:

  • Windows XP SP 3 or better
  • Apache HTTP Server 2.x
  • MySQL 5.x Server
  • MysQL GUI Tools For Windows
  • PHP 5.2.x Server

Requirements

Before installing Drupal on your local system, please make sure you have the following settings:

  • mod_rewrite enabled
  • PHP XML extension enabled
  • PHP mysqli extension enabled
  • PHP GD extension enabled
  • safe mode off
  • register_globals off

Download Drupal And Copy To Web Server Directory

  • Download the latest Drupal release and copy it to a temporary directory (c:/temp)
  • Use WinRar and decompress the targ.gz file in the temp directory
  • Copy all the files to the root of your Apache server (c:/apache/htdocs)

Create MySQL database

  • Run the MySQL Administrator program which is part of the MySQL GUI Tools. To launch it, look in the Start | MySQL menu. Login with the following information:
    Server Host: localhost
    Port: 3306
    Username: root
    Password: your password here
  • Click on the Catalogs icon. Right click in the Schemata area and select Create New Schema and give it the name drupal_mysite1 to create the database.
  • Next, click on User administration and then right click on the User Accounts area. Click on the Add new user option and enter in as MySQL user the name 'drupal_admin' and the password 'password'. Hit the Apply changes button.
  • Click on the Schema Privileges tab for drupal_admin and assign all privileges to the drupal_mysite1 schemata.

We have created a new MySQL database and a drupal database administrator account. The administrator was granted all access privileges.

Database name: drupal_mysite1
Username: drupal_admin
Password: password

Install Drupal

You are now ready to install Drupal. Fire up your browser and type in the URL to your site.

  • Select English language (or another)
  • If a message comes up about settings.php, follow the directions
  • Enter in your database information as we set it up from above
  • Configure Drupal to your sites' settings

Installing Additional Websites

The same steps above are repeated for adding additional domains to your server.

  1. Add the domain to the /windows/system32/drivers/etc/hosts file
    127.0.0.1 localhost
    127.0.0.1 www.mysite1.com www.mysite2.com
    127.0.0.1 imysite1.com imysite2.com
  2. Add to your apache httpd-vhosts.conf file the virtual host:
    <VirtualHost *:80>
      ServerName www.mysite1.com
      ServerAlias mysite1.com
      DocumentRoot "c:/apache/htdocs/"
      ErrorLog "logs/mysite1.com-error.log"
      CustomLog "logs/mysite1.com-access.log" common
    </VirtualHost>
    <VirtualHost *:80>
      ServerName www.mysite2.com
      ServerAlias mysite2.com
      DocumentRoot "c:/apache/htdocs/"
      ErrorLog "logs/mysite2.com-error.log"
      CustomLog "logs/mysite2.com-access.log" common
    </VirtualHost>

    Notice the setting of the DocumentRoots. They both share c:/apache/htdocs/. In a standard virtual host setup, it would look something like this:

    <VirtualHost *:80>
      ServerName www.mysite1.com
      ServerAlias mysite1.com
      DocumentRoot "c:/apache/htdocs/mysite1.com/"
      ErrorLog "logs/mysite1.com-error.log"
      CustomLog "logs/mysite1.com-access.log" common
    </VirtualHost>
    <VirtualHost *:80>
      ServerName www.mysite2.com
      ServerAlias mysite1.com
      DocumentRoot "c:/apache/htdocs/mysite2.com/"
      ErrorLog "logs/mysite2.com-error.log"
      CustomLog "logs/mysite2.com-access.log" common
    </VirtualHost>

    The magic is provided by Drupal which uses index.php as a boot strap loader along with its own .htaccess to service all Drupal installed websites. It is also the reason why the DirectoryIndex index.php setting in httpd.conf is so important.

  3. Create another MySQL database
    mysql> show databases;
    mysql> create database drupal_mysite2;
    mysql> use mysql;
    mysql> grant all privileges on drupal_mysite2 to 'drupal_admin'@'localhost' identified by 'password';
  4. Copy /sites/default/default.settings.php to /sites/mysite2.com/settings.php (note it ends in dot com very important!)
  5. Install Drupal

Thats pretty much it in a nutshell. Of course there is a lot of other neat stuff you can do so I'll leave it open here for another day.

Happy Drupaling!

P.S.

If you don't want to go through the hassle of figuring out if your host meets Drupal requirements and wasting time troubleshooting, use Hostgator. This site happens to be on HostGator and is running Drupal. I've used them throughout the years. Hostgator is affordably priced and very good on support.

If you sign up using Hostgator please use the banner above as we are a Hostgator affilliate. We use the ad revenue to run this website. And if you don't mind please contact me if you have done so. Thank you.