At Sparxsys we have a client who run one internal website in their company. Now recently a requirement came from one of the department that they also want to run a similar website with exact same features but with little modifications here and there. Earlier we thought that we will deploy a totally new Drupal installation but then we realized that this is a perfect use case for Drupal multisite feature.
Drupal is a powerful cms and it comes with a unique feature known as multisite. Multisite means using one Drupal installation you can run multiple sites on it i.e. each of those site will share a common code base but different database. Let me show you how to setup 2 sites on a single Drupal installation. The advantage of this approach is that the new sites will use the same Drupal code base and it becomes very easy for the developer to manage the modules and code. Of course this approach is recommended only when these two sites are for similar purpose and for the same client.
- Guest OS: centos-6.5
- Host OS: windows xp
- Server: Apache 2.2
- Database: Mysql
Now first of all make sure to setup your environment. We are going to setup 2 more websites using the same code base and eventually we will have 3 sites. Here are the steps to follow.
- Create 3 databases name them as drupal_multi, drupal_multi1, drupal_multi2. First database is for default Drupal installation and other 2 are for our other sites.
- Now edit you Apache configuration file to create 3 virtual hosts.
- Also add the hosts in windows host file. In windows xp host file is located at c:/windows/system32/deives/etc/host.
- Now go into your guest OS and move into diectory /var/www/html and create a folder named dupal_multi and do the default installation of Drupal by visiting this in your host OS browser http://drupal_multi.mycentos.com:4567/install.php
- After doing default installation go /var/www/html/drupal_multi/sites and create 2 folders namely drupal_multi1 and drupal_multi2
- Copy default.settings.php file from default folder as settings.php into drupal_multi1 and drupal_multi2 folders
- Copy sites/example.sites.php to sites/sites.php and added the following lines in the end
- Now proceed with default installation of your files by visiting these urls in host browser http://drupal_multi1.mycentos.com:4567/install.php and http://drupal_multi2.mycentos.com:4567/install.php .Just remember to select drupal_multi1 database for drupal_multi1 site and drupal_multi2 database for drupal_multi2 site
Add the following lines
CustomLog logs/drupal_multi.mycentos.com-access_log common
Allow from all
CustomLog logs/drupal_multi1.mycentos.com-access_log common
Allow from all
CustomLog logs/drupal_multi2.mycentos.com-access_log common
Allow from all
Add these lines.
$sites['4567.drupal_multi1.mycentos.com'] = 'drupal_multi1';
$sites['4567.drupal_multi2.mycentos.com'] = 'drupal_multi2';
After following these steps you will be having 2 sites installed on a single Drupal installation .You can modify the above steps to install as many sites as you want.