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 127.0.0.1, 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.

Resources

  • settings.php

Furthur reading

12 Comments

  1. Thursday, 11th Jul 2013 at 18:20

    Hi there would you mind sharing which blog platform you’re working with? I’m going to start my own blog in the near future but
    I’m having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something unique.
    P.S My apologies for being off-topic but I had to ask!


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: