Drupal: An easy way to set up multiple sites on localhost

This works for a couple of subdomains/sites only. If you need to have a load of sites or other settings this is not for you. On the other hand this method needs no web server configuration.

  1. In your systems hosts file (Windows: In your favourite text editor open %SYSTEMROOT%\system32\drivers\etc\hosts and on Linux it’s /etc/hosts.
  2. Find the line defining, i.e. your local horst, erm localhost 🙂 and append sitename1.localhost to the end of the line. do so for every site name you need.
  3. Go to your apaches/webservers documents folder holding your drupal installation. Say it’s htdocs/drupal than you need folder sites. There should be at least two folders called all and default. Copy default and name it sitename1.localhost, i.e. excactly the string you added to your hosts file (again you need to replace sitename1 by your site’s name but do include the dot!).
  4. In your web browser type sitename1.localhost/drupal to test if drupal shows up at all (meaning your OS resolves your “domain name” correctly) and if it shows your old content (meaning it works).

Now you have two options to actually set up your “new site”: Either edit the settings.php that should be in the new folder to use a diferent data base (that should be well-stocked with drupal data) or just install a fresh drupal site. You achieve the later by doing:

  1. Delete settings.php. That should leave you with a file named default.settings.php.
  2. Point your browser to sitename1.localhost/drupal/install.php and do everything like you did with the first install but use a diferent database (or the same but different database prefix).
  3. Done.


  • settings.php

Furthur reading


  1. Nag said,

    Tuesday, 3rd Jan 2012 at 09:33

    Really beautiful article. I searched in many blogs to configure multisites in one codebase. But no use for me. Some i found very difficult to configure, but they are working. This article helped me to configure without any difficulty. Its really simple and easy after reading this post.

    Thank You.

  2. Saturday, 18th Jun 2011 at 12:39

    I have learned some important things through your post. I will also like to convey that there may be a situation in which you will get a loan and never need a co-signer such as a Federal Student Support Loan. In case you are getting financing through a common bank then you need to be ready to have a co-signer ready to assist you to. The lenders will certainly base that decision on the few aspects but the largest will be your credit ratings. There are some financial institutions that will furthermore look at your job history and determine based on this but in most cases it will hinge on your credit score.

  3. fildawg said,

    Friday, 23rd Jul 2010 at 20:25

    Beautiful – works like a charm!

    Thank you!

  4. panos said,

    Monday, 5th Apr 2010 at 17:03

    hi! i would like to ask something about this:

    Now you have two options to actually set up your “new site”: Either edit the settings.php that should be in the new folder to use a diferent data base (that should be well-stocked with drupal data) or just install a fresh drupal site.

    i created a new database with a new username and password then edited the settings.php in the new folder but i get an access denied
    If i have the name password and name of the database correct what else could be wrong?

  5. Tuesday, 23rd Mar 2010 at 13:35


    Is there any way of integrating Drupal with WordPress mu? What if they shared a login cookie or something? One could then actually setup multiple sites with drupal and wordpress!


  6. ismayil said,

    Thursday, 26th Feb 2009 at 01:34

    For someone new to drupal/apache/php/etc, your instructions were super valuable and clear compared to dozens of other posts out there on similar topic. I followed the steps, it all works great, etc. So, many thanks.

    Regarding your comment “If you need to have a load of sites or other settings this is not for you,” could you explain why? Any explanation, general or detailed, would be super valuable to me (and others?) in better understanding how multi-site hosting works, I suspect. Following instructions is relative easy, groking the underlying logic is more elusive, but also more enduring.

    • sysblog said,

      Thursday, 26th Feb 2009 at 22:50

      ismayil, I appreciate acknowledgment!

      The simple reason why I wouldn’t recommend this method for more than a hand full of servers/ sites is that it would be a pain. You would at least want to hack a script that generates all your site names like devel1, devel2, devel3, etc.


  7. sysblog said,

    Saturday, 17th Jan 2009 at 14:06

    Thanks for sharing this information, ody!

  8. ody said,

    Friday, 16th Jan 2009 at 22:53

    also can do with ports; (tested on drupal 6.x)

    within apache config add listen port;
    open httpd.conf file
    find “listen 80” –or whatever is there (listen x.x.x.x:80)
    add “listen 81” –add below above
    add more? “listen 82” –also new line
    save and close httpd.conf
    stop/start apache

    now under sites folder (defualt is drupal/sites)
    add new folder named “81.default” <–copy n past default folder and ren
    and another? "82.default" <–copy n past default folder and rename

    open browser; http://localhost:81/ -or- http://localhost:82/
    if app is on own server; simply change to servername; drupal is on my server named "mydrupalhost" from browser on another computer; http://mydrupalhost:81 –or– http://mydrupalhost:82


  9. The Snuffman said,

    Sunday, 28th Sep 2008 at 20:13

    I did a Drupal upgrade 2 weeks ago from 5.1 to 6.4 and consequently my whole site was broken and I have been unable to fix.

    Now I have finally cracked how to set up multiple sites on my localhost so I can properly test everything out.

    Your instructions above were so simple, why didn’t anyone else give me that info before,

    Thanks so much!
    The Snuffman

  10. james said,

    Wednesday, 10th Sep 2008 at 20:23

    nice post man.
    keep it up..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: