Using Drupal's multisite feature you can easily run multiple sites using the same core codebase of drupal. Although the codebase is same, it is a good idea to have different databases for different sites inside the multisite environment.
Here you will see how to easily setup drupal 7 multisite in XAMPP in Windows.
1) To start, we need a default drupal installation. Suppose drupal is installed in “C:\xampp\htdocs\drupal”.
Note: If you want to know how to install drupal in XAMPP, go here.
2) We will create two sites using the codebase of the default drupal installation. You can create more.
Create two folders inside “C:\xampp\htdocs\drupal\sites”. We are naming the folders as “multidrupal1” and “multidrupal2”.
3) Copy the “default.settings.php” file from “C:\xampp\htdocs\drupal\sites\default”, and paste it inside the two new folders created in the last step. Rename both the files to “settings.php”.
4) Now we will edit the Windows “hosts” file located in “C:\Windows\System32\drivers\etc” using a plain text editor like notepad.
Note: Click here and see the steps from 2 to 3 to learn about editing the “hosts” file.
After opening the file in notepad with administrator privilege, add the following lines at the bottom of the file.
127.0.0.1 multidrupal1
127.0.0.1 multidrupal2
Save the file.
5) Now we will create Apache virtual hosts for the two sites.
Note: Here is a tutorial on creating virtual hosts in XAMPP.
6) Open the file “httpd-vhosts.conf” located in “C:\xampp\apache\conf\extra” in notepad.
Add the following lines at the bottom of the file.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/drupal"
ServerName multidrupal1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/drupal"
ServerName multidrupal2
</VirtualHost>
Save the file.
Note: Above you can see we added three virtual hosts. The first one is required to access XAMPP specific page having links like phpinfo(), phpmyadmin, etc. This page can be accessed by visiting “localhost” from the browser.
The last two virtual hosts are added for the following reason:
When you visit “multidrupal1” or “multidrupal2” from the browser, the default drupal installation code is executed. This tells drupal to match the hostname to the name of the folders created in step 2.
7) Two databases are required, one for each site. You can easily create databases using phpMyAdmin.
Note: See the steps from 3 to 7 in the drupal installation tutorial. to know how to create a database using phpMyAdmin
8) When you visit “multidrupal1” or “multidrupal2” from your web browser, if every thing goes fine, you will see the drupal's installation page.
9) From here you can follow the normal procedure to install drupal with the databases just created.
Related: