Drupal Multi-Site Introduction and Resources

Drupal is a powerful content management system currently powering 8% of all the websites on the internet. It's a robust solution with many useful features, one of which is multi-site.

This feature allows you to run multiple websites using a single installation of Drupal. Since all of the sites share the same codebase, you only need to maintain one copy of Drupal and your own contributed modules. This allows you to have consistent code managed from a central location. This reduces your overhead because updates are applied across all the sites at the same time. It also allows you to launch a new website much quicker. The sites sharing the single codebase usually have their own database which allows each site to have their own themes, modules, and content.

How It Works

If you look at Drupal's folder, you'll notice two directories. One called /sites/all and one called /sites/default. The /sites/all directory is shared with all sites, while /sites/default is the default site that is served if no mapping is specified. In a multi-site configuration, each site lives in its own separate directory so every times you add a new site, you'll be able to see it in the root folder like this: /sites/newsite. Each of these has it's own settings.php file which holds all the information necessary for the site to connect to the database and function properly.

To create a new site, you'll need to perform the following steps:

  1. Create a new database.
  2. Create a new subdirectory.
  3. Copy default.settings.php into the new subdirectory and rename it to settings.php.
  4. Adjust the permissions on the new site directory, and grant write permissions on the settings.php file.
  5. Continue the normal installation process by visiting the URL of the new website.

It's worth mentioning that while all the sites share all the themes and modules, it's also possible to create site-specific themes and modules that are available only to one site in the multi-site configuration. This gives you great flexibility and control.

Security Concerns

Before diving into resources, there are a couple of security considerations to keep in mind when it comes to Drupal's multi-site feature. If you're setting up a multi-site environment where each site will have a different administrator, you need to be aware of the fact that anyone with full administrator privileges can execute arbitrary PHP code on that site. This is done through various means which can in turn be used to affect all other sites in the same multi-site installation. Therefore, it's crucial to only assign the administrator role to someone you can completely trust.

If you do not know the person well, you might want to consider installing their Drupal website as a separate installation so they can't affect the other sites already using the same codebase.

Occasional, security vulnerabilities and bugs also pose a security risk. They allow practically anyone to access the core code that makes up Drupal. This effectively grants them access to all of your sites. When that happens, someone with malicious intentions can take all of them down in a single attack.

To Multi-Site Or Not

Multi-site is a proven and stable Drupal feature but it's not the end-all be-all solution. In certain cases, where websites have very different functionality such as using very different modules or even different versions of Drupal, multi-site is not recommended. If, on the other hand, they have similar functionality, using multi-site can definitely save you time and facilitate the maintenance process.

Resources

If this is your first encounter with the multi-site feature, the following resources will help you understand how it works and how to use it to its full potential.

Online Resources

The following list has several tutorials, ranging from beginner to advanced, on setting up and configuring Drupal multi-site.

Video Resources

If you're a visual learner, the following resources will teach you everything you need to know about working with multi-site.

The Book

There's even a whole book dedicated to the multi-site functionality:

  • Drupal 7 Multi-Sites Configuration (2012) by Matt Butcher: this book is aimed at those who already have experience with Drupal and contains practical examples and accompanying screenshots which will help you to get multiple Drupal sites set up in no time.

Get Started with Drupal Multi-Site

The multi-site functionality of Drupal is a handy way to make the management of a large number of websites easier as long as they have a somewhat similar functionality. However, it's not the right solution for every situation and you should weigh the pros and cons carefully before using it on your next project.


Further Reading and Resources

We have more guides, tutorials, and infographics related to website development and management:

Ultimate Guide to Web Hosting

Check out our Ultimate Guide to Web Hosting. It will explain everything you need to know in order to make an informed choice.