Drupal 8 Multi site configurations

 Bhavin Joshi
  • Social Media Twitter Drupal | Joshi Consultancy Services
  • Social Media Linkedin Drupal | Joshi Consultacy Services
  • bhavin [at] bhavinjoshi [dot] in (Social Media Email Drupal | Joshi Consultancy Services)target="_blank" rel="noopener external nofollow"
  • Social Media Website Drupal | Joshi Consultacy Services
25/12/2020

Drupal 8 Multi site configurations | Joshi Consultancy Services

 

To create multiple Drupal 8 sites using a shared Drupal 8 code base, you must complete

the following steps:

1. Create a new database for the site (if there is already an existing database you can also

use this by defining a prefix in the installation procedure).



2. Create a new sub directory off of the 'sites' directory with the name of your new site.

(e.g.,sites/dev.YourDomain.bhj/) See the comments in the default.settings.php file for

information on how to name the sub directory.



3. Copy the file sites/default/default.settings.php into the sub directory you created in the

previous step. Rename the new file to settings.php.



4. Activate the multi-site feature by copying (and renaming) the file sites/example.sites.php to

sites/sites.php. There is no need to edit the file unless you need site aliases. The normal site

selection rules applies.



5. Adjust the permissions of the new site directory, and grant write permissions on the

configuration file (settings.php).



6. In a Web browser, navigate to the URL of the new site and continue with the standard

Drupal installation procedure (if you get an infinite redirection loop, check if the file

install.php exists in the document root).



Note:

It may also be necessary to modify your Web server's configuration file (often named

httpd.conf for Apache) to allow Drupal to override Apache's settings. This is true for all

installations of Drupal and is not specific to the multi-site install.



Example configuration, as in /etc/apache2/sites-available/000-default.conf:



 


<virtualhost *:80>
  DocumentRoot /var/www/html/YourDomain/web/
  ServerName www.dev.YourDomain.bhj
  ServerAlias dev.YourDomain.bhj
  <directory "/var/www/html/YourDomain/web/sites/dev.YourDomain.bhj">
    AllowOverride All
  </directory>
</virtualhost>
<virtualhost *:80>
  DocumentRoot /var/www/html/YourDomain/web/
  ServerName www.dev.YourDomain.com
  ServerAlias dev.YourDomain.com
  <directory "/var/www/html/YourDomain/web/sites/dev.YourDomain.com">
    AllowOverride All
  </directory>
</virtualhost>