GET A FREE QUOTE

How to setup Multi-site in Drupal 8

Drupal 8 provides multi-site feature to use same code for different sites. You can manage multiple websites easily using the multi-site feature of Drupal 8. Multi-site allows you to use a single Drupal installation for several sites with core code, contributed modules and themes. You can also manage configuration settings and database separately for each site so it will have its own content, settings, enabled modules and enabled theme. We have shared two flow for managing multi-site feature.

How to setup multisite in Drupal 8 with different database?

Step 1: Download latest Drupal 8 and extract code in your project directory with respect to your environment like WAMP, MAMP, LAMP, XAMPP, etc.

Step 2: Go to “sites” folder and create the following folders
domain1.com , domain2.com as per the below Structure image.

Note: Please create virtual hosts (domain1.com and domain2.com) in your localhost environment.

Step 3: In “sites” folder copy “example.sites.php” and rename file to “sites.php” and add the following lines to configure the above sites in your Drupal 8 website.

$sites[‘domain1.com’] = ‘domain1.com’;
$sites[‘domain2.com’] = ‘domain2.com’;

Step 4: We need two databases for both websites so create domain1_db and domain2_db database respectively for domain1.com and domain2.com sites.

Step 5: After above configurations, install both the site using below URL and after installation, access multi-site feature.

domain1.com/core/install.php
domain2.com/core/install.php

How to setup multisite in drupal 8 within a single database?

We need to follow the same Step1, Step2 and Step3 as above.

Step 6: Create one database domain_db for managing multi-site through single database.

Step 7: After above configurations, install both the site using below URL. After installation access your multi-site feature. During the installation, use different table name prefix for each sites configuration. Please do check table prefix configuration image.

domain1.com/core/install.php
domain2.com/core/install.php

After adding different prefix to each site, it will have it’s table in single database. Please do check the attached Database Table image. We have added test1 prefix for domain2.com.

Hope, the article helps you get an overview of how to setup multi-site with same code. As a leading Drupal development company in Raleigh, NC, we have qualified team of nerdy Drupal developers. If you working on a project and need some help, please contact one of our team members and see how we can help you.

5 thoughts on “How to setup Multi-site in Drupal 8

    How can use same database .If we use prefix content for each site will be different .I want to use the content value same for both domain ,

    Hi Manmeet,

    When you install domain2.com/core/install.php, use the same username, database_name, password, but use different table prefix and try to install.

    if you still get any issues please contact on info@cmsminds.com, we will get back to you.

    No, both site content will be different if use different prefix content.

    Below is the multi site concept:
    “Drupal has a feature which allows separate, independent sites to be served from a single codebase. Each site has its own database, configuration, files and base domain or URL.”

    Refrence (https://www.drupal.org/docs/8/multisite)

    As per multi-site concept we can use one admin and one codebase but with different content, configuration, files. So may be you need to look further if anyone achieved the feature you are looking for.

    Hello,
    Do you know how can I “copy” the configuration from the main site (www.example.com) to a subsite (sub.example.com) ? Mainly, after creating the subsite, I’d like it to have the same theme and the same modules activated, but I didn’t find how to do this, in order to spare extra-work with manually configuration. I don’t have drush neither 🙁
    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

Quick Inquiry