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:
- Create a new database.
- Create a new subdirectory.
- Copy default.settings.php into the new subdirectory and rename it to settings.php.
- Adjust the permissions on the new site directory, and grant write permissions on the settings.php file.
- 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.
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.
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.
The following list has several tutorials, ranging from beginner to advanced, on setting up and configuring Drupal multi-site.
- Multi-Site Drupal: official documentation covering everything you need to know about multi-site Drupal.
- The Power of Drupal Multi-site — Part 1: Code Management: an article that gives an overview of the multi-site feature in a beginner-friendly way.
- The Power of Drupal Multi-site — Part 2: Hosting Infrastructure: part two of the article where the author goes into detail about hosting and server considerations.
- How to Set-Up Drupal Multi-Sites: a detailed tutorial on how to set-up multi-sites using Drupal.
- Why Drupal Multi-Site Is Not Enterprise Grade: an article that outlines arguments against using the multi-site feature at an enterprise level.
- How to use Drupal Console in a multi-site installation: this chapter from the book about Drupal Console, which is available online, outlines how to use Drupal Console to manage multi-site installations.
If you're a visual learner, the following resources will teach you everything you need to know about working with multi-site.
- The Great Multi-Site Debate: debate held at DrupalCon in 2014 which discusses pros and cons of using a multi-site installation.
- Working with Multi-Site: tutorial published by Drupalize.me that gives a basic overview and discusses various considerations concerning working with multiple sites in Drupal.
- Configure Apache for Multi-Site: another video tutorial by Drupalize.me that explains how to configure the Apache server to work with DrupalMulti-Sites.
- Multi-Site Setup Using a Single Drupal Instance: tutorial aimed at webmasters who want to set up different client sites using a single Drupal installation.
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:
- Google Rankings: Understand, Diagnose, and Fix: what good is a website if no one knows about it? Learn all about getting the Google ranking you deserve.
- The Ultimate List of Webmaster Tools A-Z: find all the tools you need to make managing your site easy.
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.