Drupal multiple sites installation: Tutorial

Often with your impressive Drupal installation, you would wish to run multiple sites on a single code base, each independent enough to look like an indepedent site and an independent domain name. As an example, look at the sites www.mplstutorial.com and www.shoutability.com installed on the same code base and single drupal installation.

Therefore, www.site1.com would become one site and www.site2.com would become another on a single Drupal installation.

Steps are simple (assuming you are running Drupal 5):

1. You create a settings.php file in the following directory for each domain name.

sites/site1.com/setttings.php and sites/site2.com/settings.php.

Therefore, we would have directory for 2 domain names (www.site1.com and www.site2.com).

If site1 was the first site that you installed and you had settings.php for this site in sites/default/settings.php, you can let this site remain at default directory and continue to add more settings.php files to sites directory using the domain name. Therefore, in this case, you would have sites/default/settings.php and sites/sites1.com/settings.php.

2. Now, you can configure each settings.php to access database and don’t forget to add the db_ prefix and also the base_url in each settings.php. Here, I assume you are creating separate database for each installation.

3. Once, it is done. Change your httpd.conf in /opt/lampp/etc/httpd.conf and add virtual host configurations as follows:

<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /opt/lampp/htdocs/drupal_installation

<VirtualHost *:80>
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot /opt/lampp/htdocs/drupal_installation

4.Create database as defined in settings.php for each site (i.e. site1.com and site2.com).

5. Restart your lampp server.

6. Run an upgrade or install script, that means run www.site1.com/install.php and www.site2.com/install.php.

7. Run site.com and site2.com. Both should be separate drupal installations running from the same code base. Look at the exmaple sites,www.mplstutorial.com and www.shoutability.com that have been installed using the steps above on a single drupal code base and installation.

Comments on this entry are closed.