Setting up drupal multisite on localhost

This blog post will guide you through the process of creating multisite on localhost. I usually have a couple of drupal installations in my laptop one for each branch of modules that i maintain and rest for testing new drupal themes and modules. I wanted to avoid downloading / upgrading the redundant copy of drupal core so i decided to give a try to drupal multisite feature.
Lets take my GSoC quiz module as an example to explain this. We quiz module developers support branch quiz 3.x and 4.x at the time of writing this blog post. I would like to have quiz-3.x installation at http://quiz3dev and 4.x at http://quiz4dev.
Note: There is no .com or .net domain. It is in local host and similar to http://localhost
The LAMP stack used here is Ubuntu 9.10, PHP 5.2 and Apache 2.x. My Apache's document root is at /home/sivaji/Public/ and the version of drupal that we will be using here is drupal 6.x.
Step 1: Downloading
Lets grab the recent version of drupal. Usually I use drush to install drupal core and modules. Terminal for creating database and file operation.
Project drupal (6.15) downloaded to /home/sivaji/Public/. [success]
Step 2:
This will create a directory named drupal-6.15 containing drupal 6.15 code base. Lets rename this directory to d6
$ cd d6/sites
Step 3: Directory Structure
To create the directory structure necessary for multisite.
/home/sivaji/Public/d6/sites
(We are in
sites directory of drupal file system.)
Step 3.1
Lets create settings.php and files directory for default installation and assign 777 permission for drupal installer to write configurations.
$ cp default/default.settings.php default/settings.php
$ chmod 777 default/files/ default/settings.php
step 3.2
Repeat step 3.1 for site quiz3dev and quiz4dev.
$ cp -r default/ quiz4dev/
$ chmod 777 quiz3dev/files/ quiz3dev/settings.php
$ chmod 777 quiz4dev/files/ quiz4dev/settings.php
Step 4: Database
We will create databases necessary for each site in this step.
For default installation
For quiz3dev site
For quiz4dev site
Step 5: Virtual Directory
Adding virtual directory to apache configuration file. On ubuntu 9.10 the apache configuration file resides at /etc/apache2/sites-enabled/000-default
ServerAdmin drupal@localhost
DocumentRoot "/home/sivaji/Public/d6/"
ServerName quiz3dev
<Directory "/home/sivaji/Public/d6/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin drupal@localhost
DocumentRoot "/home/sivaji/Public/d6/"
ServerName quiz4dev
<Directory "/home/sivaji/Public/d6/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
step 6: Host File
We need to add some entries in host file /etc/hosts to map the new domain name quiz3dev and quiz4dev to IP 127.0.0.1
127.0.0.1 quiz4dev
This should go below the
127.0.0.1 localhost in /etc/hosts file.
Now we need to restart the apache server to let the changes reflect.
Step 7: Installation
We are down to finish the multisite setup, now typing http://quiz3dev in browser address bar should show up a drupal installation page.
The installation procedure is very similar to usual installation, except the site specific module and themes should go into appropriate directory.
For example quiz module version 3.x should go into sites/quiz3dev/modules and 4.x to sites/quiz4dev/modules. Neighborhood modules like Devel, Gradebook, Charts can stay in sites/all/module. This makes it possible to share the Neighborhood modules across the site.
Hope this will help the fellow drupal module maintainers.
- sivaji's blog
- Login to post comments

Comments
Hi, very nice tutorial ..
but i have problem with installation procedure. When i go to http://sitename/install.php at the point where i should chose database type, i get this error.
Database configuration
Your web server does not appear to support any common database types. Check with your hosting provider to see if they offer any databases that Drupal supports.
Any suggestion what should i look into ... thank you ..
i find out what was the problem ... had to install php5-mysql
If you are using ubuntu or debian distro, you can install stuffs without much hassles using
tasksellikesudo tasksel install lamp-serversee https://help.ubuntu.com/community/TaskselHi there, I dont know if I am writing in a proper board but I have got a problem with activation, link i receive in email is not working... http://www.caucusllc.com/?4e52b5aa1c2ed00df84d4787bc5,
Hi there, I dont know if I am writing in a proper board but I have got a problem with activation, link i receive in email is not working... http://www.caucusllc.com/?9df4c5a945092a880bb0743fdce,
Hi
I done my multi site environment as instructed above. Everything is great, there is just one thing I don't know how to do.
Sites are now available directly from http://siteX - i would also want site to be available from http://localhost/siteX - so i can access it in LAN (192.168.X.X/siteX)
/var/www - there should i post some redirections or something ?
Thank you for answering .. great blog.
try this Setting up drupal multisite on localhost (with Apache Alias) http://www.caucusllc.com/blog/setting-up-drupal-multisite-on-localhost-w...