You are here

Drupal 8: file setup for multisites, single codebase

I was unable to find a coherent explanation for running multiple Drupal 8 websites from a single codebase in a UNIX environment. Here are some notes I hope will be helpful.

1. Navigate to the “sites” folder in your root directory. Change the name of the file "examples.sites.php" to "sites.php". Edit sites.php to list your individual domain names as shown in the example below. You can have an unlimited number of domains drawing on the resources of a single codebase. Make sure to remove the * before each line.

* The following examples look for a site configuration in sites/example.com:
@code
8
* URL: http://localhost:8080/example
* $sites['8080.localhost.example'] = 'example.com';
*
URL: http://domainname1.com
$sites['domainname1.com'] = 'domainname1.com';
*
URL: http://domainname2.com
$sites['domainname2.com'] = 'domainname2.com';
*
URL: http://domainname3.com
$sites['domainname3.com'] = 'domainname3.com';
*
URL: http://domainname4.com
$sites['domainname4.com'] = 'domainname4.com';
*
/// REPEAT AS NECESSARY ///
*
* URL: https://www.drupal.org:8080/mysite/test/
* $sites['8080.www.drupal.org.mysite.test'] = 'example.com';
@endcode
*
* @see default.settings.php
* @see \Drupal\Core\DrupalKernel::getSitePath()
* @see https://www.drupal.org/documentation/install/multi-site
*/

2. Go to root, and in your "sites" folder you will need to create individual folders that correspond to each of the domainnames you enumerated in sites.php. Each of these folders will contain an unedited settings.php file to which your server must be able to write in order to create your site.