Setup Drupal on Localhost and multiple sites


We 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  MYSQL GUI TOOLS 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.

If you don’t yet have PHP, Apache and MySQL installed then XAMPP will help! See also

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

Multi-site setup on localhost

Set up multi-sites there are four stages to go through, but it’s not difficult:

  1. Set up your databases, one for each website
  2. Set up each site in Drupal
  3. Edit the virtual host settings in Apache
  4. Update the Windows hosts file

In the following example we will add a local site”http://develsite1″ 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 ‘develsite1’

  1. Use GUI Tools MYSQL Browser and log into your DB server at localhost.
  2. Ctrl+D to create a new database. Type a name for your database in the ‘create database’ textbox ( ‘develsite1’ is as good as anything ) then click the create button. A new database outline will be added.
  3. Repeat for each additional site you want to set up.

2. Drupal

  1. Create a new folder /sites/develsite1. i.e. you should now have two folders in your drupal sites folder,
    default and develsite1.
  2. 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.
  3. 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 -> NameVirtualHost *:80 (Remove ## tag)
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot c:/www/
ServerName localhost

<VirtualHost *:80>
DocumentRoot c:/www/drupal6
ServerName develsite1

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 ‘develsite1’ 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: localhost testsite1

Save the file.

When working offline -without any Internet connection- with a local test site, the Windows service DNS Client (see Control Panel -> Administrative Tools -> Services) can be necessary to read and parse the hosts file. This is optional when the PC is online.

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://develsite1’ 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/develsite1/files and sites/develsite1/files/tmp,
    sites/develsite2/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

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/develsite1/modules and sites/develsite1/themes (replacing ‘testsite1’ with your actual site name)

Just it,.. simplicity is beautifull… ayess..

Re-Edit from :

For complete tutorial you can read in my personal blok at

By | 2017-09-04T06:07:27+00:00 August 22nd, 2009|Categories: TUTORIAL|Tags: , , , , , , , , |0 Comments

About the Author:

Leave A Comment