Vansh's Blog.

Setting up 2 websites using Drupal's Multisite feature

Vansh Sood
Vansh Sood

I worked with Drupal's Multisite feature to create two completely different websites, one having information about the wonders of the world and the other having information on football clubs.

The Multisite feature enables us to create multiple websites using the same root directory or the same code base. These websites are linked to one drupal folder containing the files and folders of all the websites we create. Due to this all the websites we create get linked with each other while having different structures and different content. For example, if we install a module in one of the websites, we could enable it in another linked website as the module folder will be created in the drupal folder both the websites are linked to. The websites we create are different because they have different databases while having a common code base.

The Websites:

  • Wonders of the World

    This website contains information regarding the wonders of the world, Taj Mahal, The Great Wall of China etc. This website uses the bootstrap business theme, has a simple and flat design and contains features like scroll to top. It has seven content nodes, each for a wonder, a home page and a view containing the nodes.

won

  • Football Clubs

    This website contains information regarding the different European football clubs, F.C. Barcelona, Real Madrid F.C. etc. This site uses a different database than wonders.vanshsood.com so it contains different nodes. This website uses the Nexus theme, has a beautiful red design and contains features like a slideshow. It has five content nodes, each for a football club, a home page and a view containing the nodes.

fc

Steps:

  1. Create subdomains for the websites you want to create. Example; footballclub, wonders.
  2. Create two different MySQL servers for these two subdomains and assign them two different users.
  3. Upload the drupal core installation zipped file onto your along with the subdomain folders and extract it to a folder and rename it. Example: Drupal.
  4. Create two new folders namely, footballclub and wonders in drupal/sites/.  Now copy files default.services.yml and default.settings.php from drupal/sites/default  to drupal/sites/wonders  and  drupal/sites/footballclub  as services.yml and settings.php respectively.
  5. Then create a sites.php file in  drupal/sites/  and create an array in this file containing both the subdomains and their respective folders.arr
  6. Now we need to link the drupal folder to the two subdomain folders. To do that we first need to delete the subdomain folders so that the drupal folder links its files directly in the subdomain folders. Then we need to link them by using the ln -s drupal_root folder  command in the terminalcom
  7. Install drupal in both of the subdomains using the servers created in Step 2.

I got to learn this amazing feature from the following:

My Experience

The Multisite feature in Drupal 8 is really amazing and helpful. With the help of this feature I can create multiple websites, using less space on my server, saving time by not having to install same modues and themes again and again in the websites nor do i have to upload libraries again in the directories.

flow

Sources:

Here is the video:

Youtube