A great feature that comes with Drupal 8 is that you can set up multi-sites way easier, just by using cPanel. No more code duplicates and this feature is great even for multi-language websites, but we will talk about that later on.
How to do it?
1. Download Drupal
2. Upload and extract all files into a new folder. Let’s assume you want to create two websites (fish & chips) that can be accessed from subdomains or from subdirectories. Create a user or two to access the databases you have created for the two websites (user_fish and user_chips) which will be accessed by user user_drupal who will have privileges: ALTER, CREATE, CREATE TEMPORARY TABLES, DELETE, DROP, INDEX, INSERT, SELECT, and UPDATE.
3. Make Drupal know that you will have multiple websites. Create a file called sites.php with a $sites array containing all the rules.
4. Format of each index:
'<port>.<domain>.<path>' => 'directory'. sites.php: <?php $sites = array( 'fish.me.net' => 'fish', 'www.me.net.chips' => 'chips', );
fish.me.net uses the /fish/ folder and www.me.net/chips/ uses the /chips/ folder, these folders need to be created: /drupal/sites/fish/ and /drupal/sites/chips/
5. SSH / Shell / Terminal
- Connect to your web server via SSH. If you’re on Windows, you can use PuTTY.
- The /drupal/sites/default/ site will have default files we need to copy into each of our sites. Copy these files using the cp command in the sites directory:
cp default/default.settings.php fish/settings.php cp default/default.settings.php chips/settings.php cp default/default.services.yml fish/services.yml cp default/default.services.yml chips/services.yml
6. You have your multi-site, but the two websites are empty. Why? Because now you need to make a symbolic link from /fish/ and /chips/ to /drupal/
7. Create some symbolic links that will automatically point /fish/ and /chips/ to /drupal/ like they are the same folder.
ln -s drupal chips ln -s drupal fish
8. Install Drupal and visit your websites
With multisite, the two sites can be completely different except for the fact that they share the same underlying code.
Try it now and let us know if it worked for you.