Running multiple sites on a local PC (localhost) from a single codebase, using Windows
Here's how to get mutltiple sites working on localhost using Windows XP. NB: This post was originally written for Drupal 4.6.x but has been updated for 6.x so some of the comments below are now obsolete.
Preparation
This page assumes that you have PHP, Apache, MySQL and Drupal all installed and working and have a MySQL admin tool available; the free community edition of SQLyog will do nicely, or you can use phpMyAdmin if you prefer. Again, I'll assume you've got one of these installed and connected to your database server. I'll use SQLyog here.
If you don't yet have PHP, Apache and MySQL installed then XAMPP will help! See also http://drupal.org/node/161975
Finally, I'll assume you're starting with a working D6.x installation, have followed the installation instructions and got the default site up and running. If not, start here http://drupal.org/getting-started/install.
Multi-site setup
OK, to set up multi-sites there are four stages to go through, but it's not difficult:
- Set up your databases, one for each website
- Set up each site in Drupal
- Edit the virtual host settings in Apache
- Update the Windows hosts file
In the following example we will add a local site"http://testsite1" in addition to the default site. We'll assume Drupal is installed in c:/www (and that your web root is set to c:/www in the apache config file, apache\conf\httpd.conf).
1. Databases
Firstly we will set up a new database for 'testsite1'
- Use SQLyog and log into your DB server at localhost.
- Ctrl+D to create a new database. Type a name for your database in the 'create database' textbox ('testsite1' is as good as anything) then click the create button. A new database outline will be added.
- Repeat for each additional site you want to set up.
2. Drupal
- Create a new folder /sites/testsite1. i.e. you should now have two folders in your sites folder, default and testsite1.
- Make sure the folder /sites/default contains an unmodified copy of the file default.settings.php. The installer script will look for this file when installing your new site and the install will fail if it ain't there. If necessary, extract a copy from the drupal install package.
- Also place a copy default.settings.php in the testsite1 folder and rename it settings.php. Make sure the file is writeable (i.e. the 'read only' attribute is not set) because Drupal will modify this file as part of the installation process.
3. Apache
1. Open the apache config file '\apache\conf\extra\httpd-vhosts.conf'.
2. Scroll to the end of the file, where you will find the virtual hosting setup. Assuming your websites are all located in the folder c:/www then add the following lines (edit the paths as necessary)
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot c:/www/
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot c:/www/drupal6
ServerName testsite1
</VirtualHost>There are lots of other things you can add into your VHost settings - see the Apache documentation.
4. Windows
We now need to tell Windows that the domain 'testsite1' is hosted locally, i.e. not to look on the Internet for it. Open the 'hosts' file with notepad. It can usually be found in c:/windows/system32/drivers/etc
Edit the end of the file to read:
127.0.0.1 localhost
127.0.0.1 testsite1Save the file.
Apache, again
OK, that's (almost) it. All that is left is to restart the Apache webserver. You could reboot your computer but a better way is to open a command prompt window and type 'net stop apache'. When the service has stopped, restart it using 'net start apache'. If you're using XAMPP then use 'xampp stop' and 'xampp start'.
Now when you open your favourite browser and enter 'http://testsite1' you should see the installation page for your new Drupal site. Enter the database details you created earlier and let the installer script set up the tables for you.
You can add as many sites as you need by following the process above.
Optional additional configuration
Although not essential, here are some things to help keep things tidy in a multi-site setup.
Use a separate files folder for each site
By default, all images and other uploaded files are kept in a single folder. Whilst this works, its a bit messy and better to set up a separate files folder for each site.
- Set up a separate 'files' and 'files/tmp' folders by creating the folders in your sites directory, i.e. sites/testsite1/files and sites/testsite1/files/tmp, sites/testsite2/files, sites/testsite2/files/tmp etc.
- Update the settings for each site by visiting 'admin/file system' and changing the path for the files and temp folders to sites/testsite1/files, sites/testsite1/files/tmp...etc.
Consider the best place to install modules and themes
- If you have modules or themes that you want to share between all sites then store them in sites/all/modules and sites/all/themes respectively.
- If you want them to be available only to one site then store them in sites/testsite1/modules and sites/testsite1/themes (replacing 'testsite1' with your actual site name)

Add sites as subdomains of localhost, XAMPP config
Notes:
1. It's also possible to add sites as subdomains of localhost. Configuration is similar. Advantage: it's easier to distinguish between the local and the remote site if they have the same name.
2. I've tried running multiple sites from the same codebase using XAMPP. Here are my XAMPP multisite config tips.
Amnon
-
Drupal Focused Search Engine | Drupal Israel
Personal: Hitech Dolphin: Regain Simple Joy :)
Problem setting up database tables for 4 sites
I have successfully installed a drupal local testsite with Xampp and I am attempting to set up 4 sites to run on localhost
Following the instructions at "Running multiple sites on a local PC (localhost) from a single codebase, using Windows" ( http://drupal.org/node/32715 ) I have created 4 databases and attempted to execute this instruction:
"3. Next we need to add the necessary tables. Click the 'sql' tab, then use the browse option to navigate to the 'includes' folder of your Drupal installation, e.g. c:/www/drupal-4.6.3/includes. Select the file 'database.mysql.inc' then 'go'."
When I did this it generated the following error message:
"
Error
"There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem
ERROR: Unknown Punctuation String @ 1
STR: <?
SQL: <?php
// $Id: database.mysql.inc,v 1.89 2008/01/24 10:46:54 goba Exp $" (quotation marks added by me)
It then displayed the code for the database.mysql.inc file as installed by the drupal installation and unmodified by myself.
I have scrutinized the code, but with my very limited knowledge of PHP & HTML I haven't been able to spot any discrepancy. There were no problems loading the 'drupal' database on the original install, and I have not modified the file myself..
Could there be a compatibility problem with the instructions being for drupal 4.57 (I have drupal 6.6)?
As a newbie I do well with step by step instructions.
Any help much appreciated
Peter
What happens when you don't get a Browse button in phpMyAdmin
I'm not showing a Browse button...
Bummer...
I tried pasting in the contents of the database.mysql.inc file and got a puncuation error on the first line.
I suspect that you've skipped a step or they've changed phpMyAdmin since you ran this....
So...I'm stuck on the 2nd step...
Ok, the browse "option" was hidden under 2 more windows.
Now I'm getting the same error running the script that peterbeauclerk got...
Double-Bummer...
HELP???
If you are receiving errors in MySQL then use this guide
I ran into the same MySQL database errors when trying to setup multiple sites using the guide above. I have a few ideas why that might be happening but like other following this tutorial not enough MySQL knowledge to troubleshoot the problem.
I found another guide that will help you manually setup the database. You can follow this guide through to create multiple sits or you can just use the database portion and finish this guide. They are both very similar, just slightly different MySQL steps for the most part.
This should work, because I had the same errors and I am now developing multiple sites locally.
Good Luck!
http://drupal.org/node/322363
Database setup is incorrect
Step one refers to a php include, not and sql include file. It looks like the database has to be set up from the drupal install page on your domain. Therefore, step two will not work.
Worked for me ...
... whereas this — Creating Multiple Sites On a Local Computer — did not.
This did not work for me
I have spent two nights trying to set up multi-sites to run locally. I followed these instructions and when I try to access the second site at http://127.0.0.1/litterbox/ I get:
The requested URL /litterbox/ was not found on this server.
Maybe I'm incorrect in thinking I can set up multiple sites that use a different database? I thought you could do that if you point the settings.php to the correct database.
If I go to: http://127.0.0.1/drupal/
Then I get the welcome page to Drupal. It seems that it's not even going to the sites folder.
If I type in a folder name within the sites folder I get URL was not found error.
My tree is set up like this:
www
drupal
sites
default
litterbox
All the instructions I have found sound easy and I understand what I am doing. However, nothing is working.
I'm using Drupal 6 with WAMP. Any help is greatly appreciated!!
Thanks!
Kecia