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
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/customand contain the database table creations and the logic for the custom_siteX.
- Every custom_siteX is located under
sites/siteX/modules/customyou will find only the routing settings and some customization that would not affect the database or the logic of the master_siteX modules.
sites/siteX is the same for every site except the
$settings['trusted_host_pattern'] which matches the site's URL.
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.