0

I'm quite familiar with Drupal (Drupal 7, 8 and now 9), but never made a multisite. I've been looking for some documentation and I fear that it is yet not complete for D8/D9. Many references can be found even on Drupal.org that are working for D7, but not that much for D8/D9. I've been searching on drupal.stackexchange.com quite extensively for this as well, but did not find something that could bring me forward.

The goal of my project is to have several smaller sites that all share the same base code. The setup is like

  1. site1.mydomain.com
  2. ...
  3. siteN.mydomain.com
  4. management.mydomain.com

The goal is to manage all content from site1.mydomain.com to siteN.mydomain.com via site management.mydomain.com. As data from each siteX.mydomain.com is shared with management.mydomain.com, I've split the modules into master_siteX and custom_siteX.

  • Every master_siteX is located under modules/custom and contain the database table creations and the logic for the custom_siteX.
  • Every custom_siteX is located under sites/siteX/modules/custom you will find only the routing settings and some customization that would not affect the database or the logic of the master_siteX modules.

Settings.php under sites/siteX is the same for every site except the $settings['trusted_host_pattern'] which matches the site's URL.

sites.php in sites looks like:

<?php
$sites = [ 'site1'                   => 'site1'
         , 'site1.mydomain.com'      => 'site1'
         , ...
         , 'siteN'                   => 'siteN'
         , 'siteN.mydomain.com'      => 'siteN'
         , 'management'              => 'management'
         , 'management.mydomain.com' => 'management'
         , ];

self.site.yml for Drush contains something like:

site1:
  root: <path to Drupal root installation folder>
  uri: https://site1.mydomain.com
...
siteN:
  root: <path to Drupal root installation folder>
  uri: https://siteN.mydomain.com
management:
  root: <path to Drupal root installation folder>
  uri: https://management.mydomain.com

I've been able to activate site1 without any issue master_site1 and custom_site1. When I try to enable custom_management, I'm getting a message like :

Drupal|Core|Extension|UnknownExtensionException: The module does not exist in Drupal|Core|Extension|ExtensionList->getPathName()

Clearing cache makes things back to normal. But now I'm getting a warning in admin/reports/status telling me that :

The following module is marked as installed in the core.extensions configuration, but missing:
 ¤ custom_site1

Drush as well (local install) seems to be lost when executing commands

drush @site2 <command>

Only way to ensure things to work is using the GUI. Note that there is a known issue with Drush 10.3 and below when clearing cache on multisite setups in Drupal 8 and 9.

I must be doing something wrong when configuring my multisite, because it looks to me more like cheating/tweaking than something straight forward with segmented environments.

2
  • 2
    Each site in a multisite has a distinct database, and doesn't share content (at least not natively, you could theoretically set up something that synced content between them all, of course). Unless I've misunderstood, what you're describing is more what the Domain Access module is for – Clive Mar 1 at 17:10
  • Thank you Clive. Will look at Domain Access module. Indeed it seems to be what I'm willing to do – Mathias Mar 4 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.