Last updated October 17, 2008. Created by dman on July 28, 2008.
Edited by dellintosh, add1sun, glennr. Log in to edit this page.
Software
This guide assumes you have installed WAMPServer, which you can download below:
- WampServer - includes Apache, PHP, and MySQL.
Alternatively, you can install another WAMP package, but you will need to adjust the paths as necessary.
Process
- Set up Drupal as usual
- Install WampServer (or another 'WAMP' package) and make sure that Apache and MySQL services are running.
- open phpMyAdmin in your browser localhost/phpmyadmin (or it can be launched via the WampServer icon in your system tray.)
- Create a new database -- we'll call it drupal6 because this will be our base installation which we will leave untouched. While you're here create a second and third database, which we'll call site1 and site2. You can also change the database privileges if you want, but to keep things simple here, we'll stick with the default user root and no password.
- Download Drupal 6 into WampServer's wamp/www folder (or the htdocs folder in Xampp and some other packages). (You'll need a tool like 7-zip to unpack the Drupal tar.gz file).
- Do your first Drupal installation by pointing your browser to your Drupal folder, which should be something like http://localhost/drupal-6.x. Enter the drupal6 database and user settings (root and no password in this example). Complete the installation, but then leave it alone.
- Prepare the files for your new multi-sites
- Find Drupal's sites folder, make a copy of the default folder and rename it to the URL you want for your first test site. To keep it simple, we'll make it the same as the first test site database: site1. While you're here, create files, tmp and themes sub-folders within this new folder. The themes sub-folder will be used for any custom theme you create specifically for this site. Similarly, you can create a modules sub-folder for any module you use only with this site. However, generally, I find it easier to keep all contributed modules together in the sites/all/modules folder so I can use them with all my test sites.
- Use a text editor to open the settings.php file in your new site1 folder and change $db_url line to reflect your first test site database, and the database user name and password, eg:
mysql://username:password@localhost/site1
Also, change the $base_url to the above site URL, eg:
$base_url = 'http://site1';// NO trailing slash! - Repeat the above 2 steps for the other test site (site2)
- Adjust windows so it can find the new site at a new made-up name
Find the Windows hosts file, which should be in Windows' System32/drivers/etc folder, make a backup of that file and then open the hosts file in a text editor. Here, add new lines mapping your localhost IP address to match the URLs of your test sites and your original Drupal site. In our example, it would look like this:
127.0.0.1 localhost
127.0.0.1 site1
127.0.0.1 site2
127.0.0.1 drupal6
This is telling Windows Networking that http://site1/ is a name for this machine. - Adjust Apache so it responds to requests for the new names
-
Find the Apache httpd.conf file which, in WampServer, should be in the wamp/bin/ApacheX.X/conf folder (where X.X is the Apache version number). Sorry, I can't remember where Xampp installs this, but it will be in the Apache folder. Anyway, all you need to do with this file is make sure the "Virtual hosts" line is active by removing the
#beforeInclude conf/extra/httpd-vhosts.conf. - Make a backup of that httpd-vhosts.conf file (which is in Apache's conf/extra folder), then open httpd-vhosts.conf with a text editor and add these lines:
<VirtualHost *:80>
DocumentRoot C:/wamp/www/drupal-6.x
ServerName site1
</VirtualHost>
where C:/wamp/www/drupal-6.x is the path to the Drupal installation folder and site1 is the URL for your first test site. Add another entry for your other test site, another entry for your original Drupal installation and another entry for WampServer's localhost URL (if you want to keep this active), eg:
<VirtualHost *:80>
DocumentRoot C:/wamp/www/drupal-6.x
ServerName site2
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www/drupal-6.x
ServerName drupal6
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost> - Restart Apache for the changes to take effect. With WampServer, this is done by selecting the WampServer icon in the system tray and then "Restart all services".
-
Find the Apache httpd.conf file which, in WampServer, should be in the wamp/bin/ApacheX.X/conf folder (where X.X is the Apache version number). Sorry, I can't remember where Xampp installs this, but it will be in the Apache folder. Anyway, all you need to do with this file is make sure the "Virtual hosts" line is active by removing the
- Now you're ready to install each Drupal test site using your browser, eg:
http://site1/install.php
http://site2/install.php
And that's it. You can access your two test sites anytime WampServer is running by using the http://site1 and http://site1 URLs.
As I said, it's not exactly simple, but it is well worth the effort. Now you can do whatever you like with your test sites. If you mess up with, say, site1, just delete the site1 folder, the site1 database in phpMyAdmin and the site1 entries in the Windows hosts and Apache httpd-vhosts.conf files and start again. Alternatively, if a site works out and you want to go live with it, the multi-site approach makes this easier (in my opinion).
One final caveat: I'm no expert. This technique works for me (apart from one corporate environment with a particularly annoying proxy server), but I'd welcome any feedback, especially if there are any accuracies.
Comments
. . . and when there's a proxy
I found the above technique didn't work on a heavily locked-down corporate network with a proxy server. So to get around this problem, I made every local Drupal site a subdomain of localhost. In other words, the test sites needed to have URLs such as http://site1.localhost. To do this, just follow the above technique with these exceptions:
$base_url = 'http://site1.localhost';and$base_url = 'http://site2.localhost';and$base_url = 'http://drupal6.localhost';127.0.0.1 site1.localhostand127.0.0.1 site2.localhostand127.0.0.1 drupal6.localhostServerName site1.localhostandServerName site2.localhostandServerName drupal6.localhostThis allowed me to access http://site1.localhost, http://site2.localhost and http://drupal6.localhost despite that pesky proxy.
Permissions for Windows hosts file
For those who've never edited their hosts file, here's how you get permission to do so in Vista: http://support.microsoft.com/kb/923947.
File locations for Leopard
Here is where the files are located in OS X Leopard:
/private/etc/hosts
/private/etc/apache2/httpd.conf
/private/etc/apache2/extra/httpd-vhosts.conf
httpd.conf file in Xampp setup
"Find the Apache httpd.conf file ... Sorry, I can't remember where Xampp installs this, but it will be in the Apache folder."
On my Windows Vista machine I found it in xampp/apache/conf/httpd.conf . The required line was already active, so no change was needed.
Cheerily Yours,
Tim O'Laguna
Former Commodore 64 Junior Wizard
Cheerily Yours,
Tim O'Laguna
Former Commodore 64 Junior Wizard
rename default.settings.php
In step 2.1, where you copy and rename the default folder, also rename the default.settings.php to settings.php in your new folder.
One database
You can also have only one database with different tables for each multi-site.
In step 1.3 above, create only one database.
Ignore step 2.2 and 2.3, leave the settings.php as is.
and in step 5, when you start a new site, you will be asked to enter the database name, user name and password. Enter the same database information you created in step 1.3 for every site.
Click on Advanced settings and enter a table prefix such as "site1_" or "site2_".<<< this is important!
That's it.
All the Drupal tables will be recreated with your sites prefix added to the table. There's a way where you can share common tables over all the sites, but it makes things a bit more trickier. The procedures for this are documented elsewhere.
... and when DocumentRoot has spaces
In httpd-vhosts.conf if your DocumentRoot path contains SPACE characters you will need to contain the path in quotes.
Example:
DocumentRoot "C:\Documents and Settings\Chris\Desktop\sites\drupal"
XAMPP vhost problem and solution on local Windows XP test server
Hi. I tried following the step-by-step for XAMPP and encountered an unusual problem where my http://localhost would redirect to C:/xampp/htdocs/drupal instead of the C:/xampp/htdocs that its VirtualHost tag pointed to. This seemed bizarre to me, as I had followed the steps properly, and when I would erase the VirtualHost tags for my original drupal site and test site, the localhost would indeed direct to C:/xampp/htdocs as it was supposed to.
I was able to correct this behavior by uncommenting "##NameVirtualHost *:80" (located in httpd-vhosts.conf) and changing it to "NameVirtualHost 127.0.0.1:80" and created my VirtualHost tags as follows
<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost test01>
DocumentRoot C:/xampp/htdocs/drupal
ServerName test01
</VirtualHost>
<VirtualHost drupal>
DocumentRoot C:/xampp/htdocs/drupal
ServerName drupal
</VirtualHost>
I hope this is helpful for anyone trying to set up a Windows XP test server using XAMPP.
THANK YOU!
This worked for me on my windows 7 install with xampplite.
-H
Thank you x2!!!
Worked for me also on win 7 x64
thank you thank you!
thought it was going to work...
My steps:
1 I have WampServer 2.0 installed with PHP 5.3.0, though I downloaded 5.2.9-0 because of the compatibility problem. It is running.
I created a db called drupal6, and a site1 and site2 db. (actually called them something else but will call them these names here)
I downloaded and installed Drupal 6
2. I copied the default folder twice, naming them sites/site1 and sites/site2 and I created the sub folders.
I changed the settings.php file to these:
mysql://username:password@localhost/site1
$base_url = 'http://site1'; (although the example in the settings.php file said to do it more like this: http://www.site1.com
In the WINDOWS\system32\drivers\etc\hosts file I now have:
127.0.0.1 localhost, drupal6, site1,and site2
In the httpd.conf file, I un-commented the Include conf/extra/httpd-vhosts.conf line
In the httpd-vhosts.conf file I added the following:
DocumentRoot "C:/wamp/www/drupal"
ServerName drupal6
DocumentRoot "C:/wamp/www/drupal"
ServerName site1
DocumentRoot "C:/wamp/www/drupal"
ServerName site2
DocumentRoot "C:/wamp/www"
ServerName localhost
Lastly I tried the install http://site1/install.php
But I get the error:
Failed to connect to your MySQL db server. MsSQL reports the following message: Acess denied for user 'username'@'localhost' (using password:YES).
Please advise. Thank you!
--Linda
That's a great, clear issue
That's a great, clear issue report, thankyou.
However issue reports and support requests go in the forums. We try to keep the handbook pages for actual answers. Questions incorrectly asked here may be deleted.
But since it's such a well-worded and complete question - it sure looks like you've done absolutely everything correct with the hostnames! All that is left is the error, which is, as it says, just to do with the last step and the authentication.
All you can do is check that you've made a database called 'site1' and that you've given the username full access to it, and with the right password.
... unless you actually literally changed the mysql connection string to what you wrote above! Actually "
username" not your {username}?Undo that.
Either: Put the connection string back exactly as it was (with databasename) and the install process wizard will run from scratch.
Or: Put the correct values in the connection string and the install process will run from after the DB setup.
With any manual modification to the connection string, the system thinks you've set all the connection details yourself.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
thanks!
It was the permissions. It worked!
Sorry for posting in the wrong place. New and didn't know. I have more questions, so I will look for the proper place in the forums. Thanks, Dan!
--Linda
problem with sites/sitename.com vs sites/sitename
As far as I can tell Drupal defaults to whatever the name of the sites folder is for the domain.
So, on localhost you would have "http://sitename/" and get the site located in "c:/wamp/www/drupal/sites/sitename".
However, in a production environment am I incorrect in assuming that if you have "http://sitename.com/" then you get the site located in "/home/username/drupal/sites/sitename.com", but would not get correct results if the folder was named as follows: "/home/username/drupal/sites/sitename"
The question is, in my localhost environment, is there a way to override this so that my folders match with production?
So, what I want to happen is, on localhost when I point to "http://sitename/" I get the contents of "c:/wamp/www/drupal/sites/sitename.com"
//BEGIN EDIT
I found an extremely dirty fix for this. Edit the bootstrap.inc file. Located in "drupalroot/includes/" is the file bootstrap.inc. On line 202 or so should be a function (conf_path) which handles locating the settings file for multisite installs.
I simply added the following lines of code after line 262 (after the for loop and $conf = "$confdir/default"; but before the line return $conf;):
if ($_SERVER['HTTP_HOST'] == 'sitename1') {
$conf = "$confdir/sitename1.com";
}
elseif ($_SERVER['HTTP_HOST'] == 'sitename2') {
$conf = "$confdir/sitename2.com";
}
I would strongly recommend against anyone uploading this modified bootstrap.inc to production, I have no idea what kind of damage it could cause. Basically this allows my directory structure to be as close to a 1:1 match as possible between production and staging. If someone has a less dangerous and dirty solution please offer, I would love to have it. Would even be nice to know if there is a way to put this into a module, so these things could be configured and added within Drupal. Could you extend that function to include the code somehow? A little over my head, but if it can be done, I would give it a wack.
//END EDIT
Thanks,
-junc
Folder search order
The top of settings.php contains a comment describing the search order that Drupal uses in order to find your site folder based on the web site's URL. Essentially, in your example, you would use the folder sites/sitename and then whether you're in production pointing your browser at http://www.sitename.com or in dev pointing your browser at http://sitename Drupal will still go to sites/sitename folder to serve up your site content.
Just make sure you're not overriding this behaviour with the $base_url setting (a bit further down in settings.php, just beyond the DB stuff). Make sure this line is commented out.
In Windows XP machine, the hosts file is lmhosts
Hello, a nice tutorial but I needed to learn a few things by myself. Here they are:
1) In Windows XP, the hosts file is "lmhosts". By default, there exists a lmhosts.sam(sample) file. You need to just create a new lmhosts file, but without any extension and inside it add the domain name mapping lines mentioned in Step 3
2) When using XAMPP, you also need to uncomment this line in the httpd-vhosts.conf file, found in xamppdirectory\apache\conf\extra
NameVirtualHost *:80
Then you are of to multisite installation. Bingo..!!!
Ritz,
Ritz Softec.
install multi-site on a desktop running xampp worked fine.
I installed another site on my drupal desktop installation without any significant issues. I am planning to perform similar mufti-site installations on windows 2003 and windows 2008 servers. thank you for the detailed instructions; it made my "proof of concept" task much easier.
Joe (aka Jose) Berrios, B.S., M.S., M.P.M., C.I.P.M.
Wisdom Tooth Web Applications
WB2BWU
(347) 644-7680
AOL IM: bnyjoe
Skype: wb2bwu
home page:
http://sites.google.com/site/thehomeofwb2bwu/
http://wb2bwu.org/drupal617/
http://wb2bwu.or
Sorry i was excited....let me
Sorry i was excited....let me tell you one thing that when you make a copy of default.setting.php in site1 folder, dont make any change in db_url line.
Very Good Blog
Thankyou so much dude................
Really this is very awesome blog for any user who want to implement multisite in drupal. Before reading this blog i waste most of the time on using modules like Domain Access and Multimanager etc but every time i struck somewhere in middle....
But this time i'm really glad to see it is implemented very easily.
Thanks a lot dude.............. Really very good blog.
Pushpinder Rana
multisite only looks at default settings prompting install
I've setup the first site as described and thought everything was working fine. When attempting to install the second site, it only resolved to the first site already installed because the install wrote all the settings to the default settings.
I copied the newly created default settings into the firstdomain.org folder and reset the original default settings, but now, I simply get prompted for installing a choice of 3 domains, default, domain1 and domain2 no matter what I type into the URL.
What is wrong? This test is on a local XAMPP windows setup, and quite frankly not much different with MAMPP on the Mac.
Tried lots of variations on the settings, deleting, including, not sure where to go now.
Version 6 Drupal
my solution here for multisite issue prompting install.php
My situation is resolved as follows:
1- Install the default profile, this is just to have another base install to toggle, not even sure it's necessary or recommended but I did it.
2- Make sure the local hosts file contains the EXACT domain name including the sub, so it is subdom.primarydomain.com (or org), read up on the org domain extension in that Drupal has a sequence of searching the settings in case that ORG is the most important site.
3- Make sure the folder name within the sites folder is also named EXACTLY so it will be sites/subdomain.primarydomain.com
4- In MY case I left the modified default settings as per the installation of the first install (1), so it actually points to a DB and hence does not prompt me for a fresh install of any site. I found that without this in MY case it prompted for an install assuming nothing was installed yet, if it had no DB for instance.
Now, I'm happy, can go to any of my multisites with no issues (YET!?)
THANK YOU!!
I've been searching for the right method to make it work on Windows.
For some reason , Junctions and symlinks did not work for me, but your explanation, did it!
Thank you, thank you, thank you!
crash on install
I've got as far as the install page on the second site but when I click "Install Drupal in English" i get a "page cannot be displayed" message.
any ideas?
thanks
very helpful tutorial
very helpful tutorial
Thank You
Hi,
Excellent Tutorial.. worked like a charm ! :)
Sarang
Obrigado!
Your tutorial helped a lot!
Process failed to start
If I do the 4.1,
exactly: "Anyway, all you need to do with this file is make sure the "Virtual hosts" line is active by removing the # before Include conf/extra/httpd-vhosts.conf. "
my fresh Acquia Drupal Stack can not work because the Apache Web Server 2.2.17 throw a "Process failed to start" exception with Win7 (32).