Community Documentation

Installing Drupal Multisite on XAMPP for Windows

Last updated March 31, 2013. Created by Fohsap on July 13, 2012.
Edited by ludovids. Log in to edit this page.

My setup: Windows XP, Drupal 7, XAMPP default installation.

1) Extract D7 to a directory on your harddrive of your choosing. We will call it the DocumentRoot ("docroot" for short) directory. If you do not want to create a unique folder on your harddrive, and you just want to use the default (c:/xampp/htdocs/xampp) as your docroot, then you should extract D7 to that directory (c:/xampp/htdocs/xampp). If you decide to do that, I think that you can just skip step 2, but I have not tested that theory, and I'm only about 30% sure that you can skip step 2. I would recommend completing step 2.

2) Use vHosts and hosts to create multiple localhost-only domains:

  • example_site.com is mapped to 127.0.0.1 in hosts (c:/windows/system32/drivers/etc/hosts). Here's my working example, which feels very safe and reliable to me:
          #<localhost>
          127.0.0.1    localhost
          127.0.0.1    localhost.localdomain
          127.0.0.1    local

          #You will not be able to access your website except locally (not at other people's houses).
          #If the URL is already owned, you will no longer be able to browse to that URL without getting your site.
          #<local multisite url listing>
          127.0.0.1    example_sitename.com
          127.0.0.1    example_sitename2.com
          #</local multisite url listing>
          #</localhost>
       
  • example_site.com is set, as follows, in my vHosts file (c:/xampp/apache/conf/extra/httpd-vhosts.conf by default):
          ## You must restart Apaches for the changes to the vHosts file to take effect. ##
          ## Site 1 desired url is example_sitename.com, as seen in the hosts file.  It must match the hosts file. ##
          <VirtualHost *:80>
          ServerName example_sitename1.com
          DocumentRoot "C:/example_docroot1"
          <Directory "C:/example_docroot1"> //same as one line above
          Options +Indexes +FollowSymlinks +ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
          </Directory>
          </VirtualHost>

          ## Site 2 ##
          <VirtualHost *:80>
          ServerName example_sitename2.com
          DocumentRoot "C:/example_docroot2"
          <Directory "C:/example_docroot2"> //same as one line above
          Options +Indexes +FollowSymlinks +ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
          </Directory>
          </VirtualHost>
       

This vHosts file has been extremely successful for me. I have tested on four XP machines over the past several weeks, and it has worked on all of them, without a hick-up. I have tested other blocks from other forums, and many of them have been glitchy. I've been told it could be made safer, and I'm curious as to how; however, I've also been told that this is safe. I recommend that you start by just copying and pasting the above block.

3) Setting up the sites directory and the databases. Note: I have not done multisite on a single database. If you have, please add that info.

I copy c:/example_docroot/sites/default/default_settings.php and paste it as c:/example_docroot/sites/default/settings.php. I create a new MySQL database by browsing to http://localhost/phpmyadmin. I create a new user at phpmyadmin, and then I give the new user I've just created, as described in this paragraph, full access on the new database I've just created, as described in this paragraph. I check to make sure that the new user is @localhost via phpmyadmin, which is rarely the default, at the user edit page in phpmyadmin.

4) Save a copy of sites/example_sites.php as sites/sites.php and alter the $sites array in the new file.

c:/document_root/sites/sites.php

  $sites = array(
    'example_sitename.com' => 'default', //For your default site.
    'example_sitename2.net' => 'example_folder2', //For your second site.
  );

You do not need to list the complete path to the folder! You only need to list the folder names (in the above block they are "default" and "example_folder2"). The key in the key-value pair of the $sites array must match the url you used in your hosts and vHosts files! Most likely the most common errors people will run into will be:

  • Syntax errors: solved by going through each line of code line-by-line and checking the results. And...,
  • having mismatching urls between the hosts, vHosts, and sites files.

If your hosts and vHosts files are correctly configured, you have your settings.php files in place and correctly configured, and your sites.php file has a good key-value pair, all that's left to do is browse to the urls and run the installers!

When I open my browser, which is Chrome, and browse to example_sitename.com, I get the drupal installer, naturally. This installer installs the default site. I complete the installer by filling in the forms. If you have trouble filling in the forms, check the forums.

After installing the default site, I open my browser--Chrome-- and browse to example_sitename2.com. I get another installer! Yay! Success! If you successfully installed the default site and browsing to example_sitename2.com gives you an installed copy of drupal rather than the drupal installer, then your sites.php file is not correctly configured. If you get an error, please comment.

5) Back up and delete the install.php file from your docroot. You shouldn't keep install.php in the docroot. You should wait until you're going to install a new site and then save a copy of your backup to the docroot as install.php. Delete this new install.php when your next installation is complete, too.

Comments

Intermittent failure

Sometimes this method doesn't work.

--

Man, this takes forever... Just forget it.

vhosts

I believe your ## Site 2 ## vhost edits are incorrect. Why is the ServerName the same as Site 1?

Page status

Needs technical review

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Site administrators, Site builders
Level
Advanced
Keywords
Multisite, windows, xampp
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here