Hosting multiple sites drupal sites

There are many reasons why a systems administrator or developer may choose to host multiple sites on the same server in a multisite configuration. For example, such a configuration could:

  • Enable you to build an efficient development environment
  • Allow you to stage and test a site before it goes public
  • Let you run different software on the same site
  • Enable sharing of a single code base across several sites
  • Leverage shared hosting
  • Allow you to run similar secure (HTTP over Secure Sockets Layer [HTTPS]) and standard (HTTP) sites on the same server
  • Ease server administration

Not all of these reasons, however, are best addressed with Drupal's multisite feature. This articles focuses on just one strategy: how to use Drupal's built-in multisite support to create and serve several sites from one instance of Drupal.

Hosting multiple sites drupal sites they have

Basic considerations

Using the Drupal content management system (CMS) to create a multisite configuration has several distinct advantages, one of which is that it is probably the easiest configuration to set up and maintain. Another is that data duplication is minimized because Drupal is installed in only one place on your server. Finally, Drupal has a wealth of contributed modules that can be used to augment multisite handling, offering advanced capabilities to all the sites in the arrangement. The combination of added features and simplified administration would be a boon for anyone wanting to set up and administer a multisite arrangement. Nevertheless, there are a few drawbacks to using such a configuration, and two in particular deserve clear mention: security and sharing.

The sites in a multisite installation share the same code and thus the same files. As a result, anyone who gains access to the server's file system for one site also has access to all the files used for all of the sites on that multisite installation. Therefore, in cases where different people are managing different sites within the arrangement, it may not be quite secure. If security among sites is a primary issue, or if different people manage the various sites, Drupal's built-in multisite functionality may not be the best solution. Instead, consider giving each site its own distinct Drupal instance. Although the advantages of easier administration that the multisite arrangement affords will be lost, your sites will be better protected from mishaps.

The second concern — sharing — centers around database access. Even though Drupal's multisites share the same source code, they do not share the same database data. Thus, nodes, users, and comments in one site are not accessible by default from other sites. This behavior can actually be regarded as a good thing, but in situations where the administrator may require that all the sites share information, it may be a limitation for the design of Drupal's multisite feature. Nevertheless, the sweet spot for Drupal's built-in multisite support is that modules, themes, and, even to some extent, uploaded files, can be shared across all the sites. In addition, the same or custom files can be retained in different folders corresponding to the different sites in the configuration. If it's important that all content be shared, consider using a multidomain feature, which is easily provided by a module of the same name.


Installing Drupal for multisite use

After downloading the Drupal archive (see Related topics for a link), extract the file and copy the resulting folder to the document root of your web server. This task isn't difficult with a suitable FTP client; with Secure Shell (SSH) access to your server, the task is even easier. Simply run a wget command to download the archive file from the repository, and extract it to produce the Drupal installation folder. (If your development environment is local, stand by for more options.) Name the installation folder /goodsite .

Three different sites will be created for this exercise; therefore, three different databases are needed — one for each site. Using phpMyadmin from the Cpanel of your server, this task is easily accomplished. Next, install the framework. Two tasks must be performed, however, before using your web browser to run the installer:

  • Provide Drupal with the information it needs about the sites you intend to run.
  • Pass the site-specific configuration data from Drupal to all of the sites.

To achieve the first task, create a special directory for each site. For the second, locate a settings file in each directory. The objective is to set up one master installation with two sub-sites. Each sub-site shares the same files as the core, but each will have its own separate URL and database. The URLs of the sites to be created are:

Installing the first host

After placing the Drupal source code in the document root and having created the MySQL databases, begin installing the first site and the master domain.

The master domain

The master domain name is the URL from which the main site will be accessed (in this article, The primary purpose of the master domain is to host the base Drupal installation. Regardless of whether this domain is used as one of your sites, if any sub-sites fails, their URLs will default to the master domain; therefore, it is a good idea that this site contain information relevant to the sub-sites, such as contact information.

As mentioned, a subfolder must be created within the main Drupal folder for each sub-site. What many would imagine the most difficult task in Drupal's multisite installation is simply routine: Let Drupal know what sites you want to host, and simply create subfolders for those sites in the /sites folder.

In the Drupal main root folder is a directory called /sites. If you've administered Drupal before, you know all non-core code ought to reside within this folder. In the default Drupal installation, the /sites folder contains two directories. The first, called all/, is where you should put downloaded themes and modules. The all/ directory is the location for information shared across all sites. The second folder, named default/, is where configuration files should be kept, as well as non-core and custom themes and modules. Drupal typically searches the default/ directory for site configuration information unless it is instructed otherwise. Note, however, that these are assumptions for a generic, single-host site — not necessarily for a multisite installation.

Creating the subfolders and files

A big tip for building multisite Drupal is that apart from the all/ and default/ folders, other folders can be created in /sites, and Drupal will assign them special meaning. More specifically, Drupal assumes that all other directories found in the /sites folder represent a hostname or a hostname pattern.

You create a subfolder in the pattern /goodsite/sites/ under the /sites folder for all sub-sites, substituting your intended URL for the name of each sub-site folder. In this example, you have the following sub-sites, as shown in Figure 1.

For each sub-site, complete the following steps:

  1. Copy the file default.settings.php from sites/default to each sub-site folder, and rename it settings.php .
  2. Use CHMOD to set the permission on settings.php to 644, if it is not the current permission.
  3. For a Drupal, Version 6 installation, create a folder named files under each sub-site, and use CHMOD to change the permission to 755.

This is a folder inside which Drupal is able to write content — typically, uploaded files, image thumbnails, aggregated Cascading Style Sheet (CSS), and JavaScript files. These files are not stored in the database, but rather in the file system, so you must have a directory in which these files can reside.

By default, Drupal looks for a subdirectory named files/ within the directory of every site. In a default Drupal installation, this folder would be in sites/default/files/.

  • Create a folder called modules for each sub-site.

    This is the folder in which any modules specific to that sub-site reside. Any modules that all sites will use should reside in the sites/all/modules folder.

  • Create a folder called themes for each sub-site.

    This is where any themes unique to that sub-site are placed. Any theme that all sites will use should reside in sites/all/themes.

    Now, point the sub-site URLs to your web server, if they are not administered by the same hosting company. If you use different hosts for the various sites, you will need to change the Domain Name System (DNS) information (both the registrars and the hosting companies should be able to tell you how to do so). Thereafter, you will have to "park" that domain on top of your primary domain — in this case, From this point, you have a few alternatives, the more difficult of which involves using what's called a symlink. Parking is much simpler, however; so in your Cpanel, click on Parked Domains. Add and in New Domain Name. and then click on Add Domain.

    Creating the multisites

    There are several ways to go from here, but again, let's take the easiest route: directly loading the database for each sub-site with the tables created in the master site installation. To do so, you must create a dump of the database tables from the master site installation and save it locally. Then, either upload this file with phpMyadmin or open it using a code editor. To use the second option, perform these tasks within phpMyadmin:

    1. Go to the database created for the sub-site.
    2. Go to SQL. and then paste all of the code from the Structured Query Language (SQL) dump there.
    3. Click on Go .
    4. This procedure reproduces the master site database tables in the sub-site database.

      Next, open the settings.php file for each sub-site, and look for the following line:

      Change this database connecting string to reflect the parameters for the sub-site database (username, password, hostname, database name). Now if you go to, you should get the standard "Welcome to your new Drupal website" page, as shown in Figure 2. Repeat these steps for all additional sites.

      Creating multisites from sub-domains

      There is another way to quickly create multisites by first detailing them as sub-domains from the Cpanel. In this method, however, you must initially create folders for each site under /goodsite/sites, this time using the following convention (see Figure 3):

      Note that the sub-domain folders must have the same names as the sub-domains themselves. As before, put a copy of default.settings.php in each sub-domain folder, change the file name to settings.php. and issue CHMOD to change the permission to 644.

      Now, return to Cpanel and create two sub-domains:

      Create a symlink

      A symlink is a file that contains a reference to another file or folder in the form of an absolute or relative path and is created to affect path name resolution. Use any code editor to create a file called symlink.php. and then add code similar to the following:

      In this case, the file would look something like this:

      Put this symlink in the main directory of the main site, and run it from the URL If the code syntax is good, you should see a blank page; otherwise, you will see error messages. Tweak the code in this file until it comes out correctly.

      Configure .htaccess

      Now open the .htaccess file in any code editor. Look for the following line:

      Remove the hash sign ( # ), and add the following line before saving the changes:

      Here's what .htaccess should look like when finished:

      This redirection makes it possible for both and to be redirected to the same site. If everything has been done correctly, you will be directed to the installation page when you access the sub-site URLs and

      With all the sites installed, it's easy from the Cpanel to associate the site using a redirect to the URL

      Multisite on a local host running Ubuntu

      Running a multisite installation on Ubuntu is a bit more complicated than what you have done so far for remote hosting. A multisite installation can be easily configured using the method outlined in the following sections.

      Create a new hosts folder

      Begin by creating a folder called goodsite in your home folder using the following code:

      The result should be -> /home//goodsite .

      Now copy all your Drupal files into this folder.

      Edit the hosts file

      Edit the hosts file by opening a terminal window with the following command:

      You can then add any site name in the format For this example, add the following lines:

      Edit the sites available

      Now go to the sites-available folder to create a file called using the following commands:

      The first command goes to the sites-available folder; the second command copies the default file and renames it The third command opens the file for editing. Add the code shown in Listing 1 to the file.

      Save, enable it, and then reload Apache using the following commands:

      Create sub-site folders

      Create your sub-site in the /sites folder /home/[your ubuntu login name]/goodsite/sites/, and then add settings.php to the new folder. If you have already navigated to the sites/ directory, copy the settings.php file with the following command:

      Run sub-site installation

      Open your browser, then type You should see the installation setup page. Make the settings.php file read-only again to avoid security messages, then run the sub-site installation.

      Next, create a site folder and run the installation for as well as any other sub-sites mentioned in your hosts configuration.

      Multisite modules

      Modules are used to extend the functionality of a basic Drupal installation and come in various categories, from administrative to actual performance-enhancement functionalities. Several modules can assist in creating a multisite or similar configuration. For details on how to use these modules, consult the installation documentation for each module.

      The Domain Access modules

      The Domain Access modules (see Related topics for a link) enable the creation of a multisite using a single code base, a shared user database, and shared sign-on but with different content databases. Such a configuration is different from what we have done in this article. Domain Access is actually described as a set of modules that facilitate running a group of sites by using one basic Drupal code installed inside a single shared database. These modules enable all of the sites to share users, content, and settings if they have been preconfigured to operate in such a way. The Domain Access modules employ Drupal's Node Access System to establish which content should be made available on each site in the multisite arrangement. The modules, unlike other multidomain modules, also control user access on the basis of the active domain the user is viewing, not on the basis of the group or site to which the user belongs.

      The Multisite Manager module

      The Multisite Manager (see Related topics for a link) is a contributed module that allows creation of new Drupal sites from a base Drupal site without the need to access the installation database. By default, the new site is installed in the same database as the base installation, but with a different prefix. Otherwise, if the current user has access permission to create a database, the installation could possibly be done in that database.


      This article explored how to create a multisites configuration using Drupal as the base CMS. You installed the master site and located the sub-sites within its directory structure. You learned how to run multisite installations on a remote server by using the administrative facilities your hosting company provides. You also learned how to create a multisite installation on a local machine — specifically, on a computer running Ubuntu Linux®. This article also introduced two Drupal modules that can assist you in the creation of both multisite and multidomain configurations.

      Related articles

      Multi sites drupal hostingIf you are running more than one Drupal site, you can simplify the management and can upgrade your sites by using the multi-site feature. Multi-site allows you to share a single Drupal...
      Hosting multiple sites drupalThere are many reasons why a systems administrator or developer may choose to host multiple sites on the same server in a multisite configuration. For example, such a configuration could:...
      Hosting two wordpress sites on one serverMultisite feature If you want multiple blogs using WordPress, use multisite feature to create what was referred to as a network of sites. This feature was implemented by merging WordPressMU...
      Hosting multiple sites drupal tutorialDrupal's Mutlisite feature sounds like the Holy Grail for whenever you want to run multiple Drupal sites. However, the answer to "Should I use Multisites?" is best discovered by knowing what...
      Printer friendly pages drupal hostingDrupal is a robust Content Management System that runs on a LAMP server. The LAMP server uses MySQL by default, but PostgreSQL can also be used with Drupal. It can host blogs, forums, and a...