Drupal- Ten Easy Step to Step Guide on How to Run Multiple Web Sites from single Drupal Installation with the same code base (multi-site)

The key is that you need to create multiple MySQl database (for different websites), create a new directory in “/sites/your-site-name” folder which includes “default.setting.php” file renamed to “settings.php” and finally have your virtual host settings correctly setup. Thats it!

It’s really very easy to install/use your single Drupal installation for multiple websites.

In web 2.0 internet world everyone wants to increase there customer or visitor base and hence have multiple websites, domains for different countries.

Like IBM, cisco, etc. have multiple websites with multilingual features.

Anyways in this article we will concentrate on step to step guide on setting up a single Drupal Installation for multiple websites (multi-site).

1. Set up a standard drupal installation in your web server web root also know as document root. We name the document root/website folder as “unclecode” with a MySQL database “unclecode_usa”.

2. Create a virtual host entry. I am using Apache webserver so my httpd-vhosts.conf file looks like-

<VirtualHost *:80>

ServerName localhost

DocumentRoot “C:/wamp/www/unclecode”

<Directory “C:/wamp/www/unclecode/”>

Options Indexes FollowSymLinks

AllowOverride all

#   onlineoffline tag – don’t remove

Allow from all
Order Allow,Deny
</Directory>

</VirtualHost>

The second website vhost entry looks like below-

# This site redirects to new database installation but same code base
<VirtualHost *:80>
ServerName unclecode.uk
ServerAlias unclecode.uk
ServerAdmin webmaster@dummy-host2.locahost
DocumentRoot “C:/wamp/www/unclecode”
<Directory “C:/wamp/www/unclecode”>
allow from all
order allow,deny
</Directory>
ErrorLog “logs/dummy-host2.localhost-error.log”
CustomLog “logs/dummy-host2.localhost-access.log” common
</VirtualHost>

3. So the installation path on windows looks like- “C:\wamp\www\unclecode”. This can be different depending upon the webserver you are using.

4. You can access the website as http://localhost or as http://unclecode.com. Refer to #7 below.

5. Install drupal on this path with standard installation steps.

6. Now make sure your Drupal website “unclecode” is working by accessing http://localhost or as http://unclecode.com.

7. Open your windows host file found at “C:\WINDOWS\system32\drivers\etc\hosts” in a text editor like notepad and append following two lines to the file-

# The below is a default entry. Do not modify the below line

127.0.0.1       localhost

# add the below two drupal sites

127.0.0.1       unclecode.com

127.0.0.1       unclecode.ac.uk

The above means that when you access “localhost”, “unclecode.com” or “unclecode.ac.uk” then it will be redirected to your local copy of single drupal installation “C:/wamp/www/unclecode/”.

8. Now setup Drupal for a new site. Create a new MySQL database “unclecode_uk”.

9. Create a new sub directory in drupal “/sites/” folder as “sites/unclecode.ac.uk”. So the path looks like- “C:\wamp\www\unclecode\sites\unclecode.ac.uk”. Now copy “default.settings.php” found in “sites/default/default.settings.php” to “sites/unclecode.ac.uk/settings.php”. You need to rename “default.settings.php” to “settings.php”. Adjust the permissions of the new site directory and grant write permissions on the new “settings.php”. Open settings.php and provide the database name as “unclecode_uk” with MySQL username and password.

10. Now if you are logged into first Drupal installation (http://unclecode.com) then make sure you logout. Now in a Web browser, navigate to the URL of the new site i.e. “http://unclecode.ac.uk” and continue with the standard Drupal installation procedure.

You are done.

Tip: You can use various other modules like domain access, i18, translation management to create multiple sites with multi-lingual features.

You can also create multiple web sites in Drupal which runs with single MySQL database, with different domains which are redirected to a single/default site with different language through Domain Access module.

Bookmark and Share
Both comments and pings are currently closed.

Comments are closed.

n