Last updated November 20, 2015. Created on June 10, 2010.
Edited by Johnnie Walker, 2020media, lisarex, Log in to edit this page.

This page describes the minimum required steps for configuring a multi-site development environment on a Linux machine. The steps go through how to set up two development sites with the names testsite and testsite2. By replacing these names with ones of your choice, you can set up your personalized multi-site testing environment in Linux. The sites will share the same Drupal installation, but will use different databases. These instructions assume that you have the necessary system requirements for Drupal and know how to use a Linux command prompt.

Step 1: Download and uncompress Drupal

It is not recommended to install Drupal through your package manager, as the available Drupal package is usually outdated. You can download and uncompress Drupal by following the steps on the Download and uncompress Drupal page of the Installation guide, as this step does not differ from a normal installation.

Step 2: Set up your hosts file

Add the following lines to /etc/hosts:    testsite.localhost    testsite2.localhost

Step 3: Set up Virtual Hosts

Add the following code to /etc/apache2/httpd.conf:

<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName localhost
<VirtualHost *:80>
    DocumentRoot /var/www/drupal
    ServerName testsite.localhost
<VirtualHost *:80>
    DocumentRoot /var/www/drupal
    ServerName testsite2.localhost

The stanza (paragraph) about /var/www/html is there to preserve the possibility to put non-Drupal sites in that directory. If you want only Drupal sites to be served, you can ignore it. You should also change the directory /var/www/drupal to the location you uncompressed Drupal in step 1.
After this, restart Apache:
sudo /etc/init.d/apache2 restart

Step 4: Set up your databases

Create two databases using the instructions found on the Create the database page of the Installation guide. Name one of them testsite and the other testsite2.

Step 5: Set up your sites folders

  1. From the command prompt, navigate to /var/www/drupal/sites/ or wherever you have your sites folder installed.
  2. The default directory will serve as a template for our other sites. Create a writable files directory in the default directory to make sure every one of your site folders get this directory:
    sudo mkdir -pm 777 default/files
  3. Copy the default directory to create your new site directories:
    sudo cp -a default/ testsite.localhost
    sudo cp -a default/ testsite2.localhost
  4. Rename the default.settings.php files to settings.php and change the permissions to make them writable, so that the web server can access them in step 7:
    sudo mv testsite.localhost/default.settings.php testsite.localhost/settings.php
    sudo mv testsite2.localhost/default.settings.php testsite2.localhost/settings.php
    sudo chmod a+w testsite.localhost/settings.php
    sudo chmod a+w testsite2.localhost/settings.php

Step 6: Configure your sites to use the appropriate databases

  1. In the /var/www/drupal/sites/testsite.localhost/ directory, edit the settings.php file as follows (assuming you are using MySQL):

    For Drupal 6:
    $db_url = 'mysql://testuser:password@localhost/testsite';

    For Drupal 7:

    $databases = array (
      'default' =>
      array (
        'default' =>
        array (
          'database' => 'testsite', 
          'username' => 'testuser', 
          'password' => 'password', 
          'host' => 'localhost', 
          'port' => '', 
          'driver' => 'mysql', 
          'prefix' => '', 
  2. Repeat for /var/www/drupal/sites/testsite2.localhost/, except replace testsite with testsite2.

Step 7: Run the installation script for your sites

In a web browser, visit http://testsite.localhost/install.php and follow the instructions found on the Run the installation script page of the Installation guide. Repeat for http://testsite2.localhost/install.php.

Step 8: Remove write permissions from your sites' settings.php files

You don't really need to do this, since this is only a development environment, so we're not really concerned about security. Nevertheless, it's a good habit to get into:
From the command prompt, navigate to /var/www/drupal/sites and remove the write permissions for the settings.php files:
sudo chmod a-w testsite.localhost/settings.php
sudo chmod a-w testsite2.localhost/settings.php

Step 9: You're done!

You can visit your sites at:

Other resources

Local multi-site installation of Drupal 7 on Linux

Looking for support? Visit the forums, or join #drupal-support in IRC.


nelcalb’s picture


Just in case, for people using LAMPP (Xampp for Ubuntu), there is no:


Instead, you can find httpd.conf on:


Nelson C.

pete.otaqui’s picture

Setting up extra config for every virtual host is ok, and certainly if you need specific config that's the only way to go.

However, a lot of projects can actually work on per-server config - and in that case it's much easier to use vhost_alias and VirtualDocumentRoot to map subdirectories to subdomains. I wrote a guide about that:

pradeep_0306’s picture

When i trying to call http://testsite.localhost/install.php throwing error

Forrbidden Access to Page and in apache2/errorlog
its showing

AH01276: Cannot serve directory /var/www/html/drupal/sites/testsite.localhost/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive, referer:

Note:When we are placing all files in drupal again in /sites/site1 its showing installation prompt