Step By Step Guide To Create Multi-Site In Drupal With Lando

Step By Step Guide To Create Multi-Site In Drupal With Lando

Step By Step Guide To Create Multi-Site In Drupal With Lando

This tutorial will teach us how to set up Drupal multi-site utilizing Lando, with a shared (single) codebase and a different database for each site on a local computer.

What is Lando?

Lando can be considered a Docker Compose tool as well as an abstraction layer and superset of the latter. Lando, as an abstraction layer, significantly lowers the difficulty of spinning up containers by defining “sane defaults” and exposing only the configuration that is pertinent to a particular “service.”.

When should I think about having many sites?

  • Let’s first examine when multi-site setup is appropriate before delving into the technical aspects of doing so.
  • The arguments provided and the Pros & Cons listed below will assist you in determining whether or not multi-site is appropriate for your sites.

 Pros:

  • Simple to keep up:
  • Reduced expense of development:
  • Assign distinct features and themes to every website:

Cons:

  • lone point of failure:
  • Site traffic control:

Please be aware that we won’t be going over how to install Lando. For further information, view the official Lando document.

Steps To Create Multi-Site In Drupal With Lando

Step 1: let’s configure a multi-site using Lando.

  • Lando utilizes a configuration file, which enables us to launch many services and ensure optimal operation of our program. Normally, all that would be required to run lando and Drupal without any issues would be to run the lando init command. This configuration file would then be generated automatically.
  • In the event of a Drupal Multi-site installation, on the other hand, we will need to generate our own Lando configuration file and adjust it to suit our requirements, including the URLs for our subdomains and the access information for every database, among other things.
  • While there are numerous additional configurations that can be added to a project of this kind, I’ll provide you with the basic file below, along with an explanation of each area that’s crucial, so you can use Lando to launch multiple Drupal sites. Open the folder from which you obtained the Drupal Base files, and use the following code to create a file called.lando.yml:

Drupal With Lando

Explanation:

  • The project name and the primary web root configurations are located in the first section of the configuration file.

Drupal With Lando

  • The Proxy section is where we will specify the various domains for our Drupal sites. As with a standard Drupal Multi-site installation, the main name of each domain must match its installation folder.

Drupal With Lando

  • All of the data pertaining to our databases will be defined in the final section of the configuration file. Keep in mind that you may use the information command to verify all the details once Lando has started:

Drupal With Lando

Step 2 – Configuring the multi-sites and main Drupal

At this stage, we need to make a few tweaks before we begin our Drupal project:

  • The file example.sites.php should be renamed to sites.php and the folders that each of the example domains will point to must be added inside.

Drupal With Lando

Drupal With Lando

  • Make the folders with the names that match the domain names you specified in the configuration file. The folder names must match the names you entered in the sites.php file from the previous image and the lando configuration file.

Drupal With Lando

  • Configuration files can be added to many sites. Two files are necessary for every Drupal installation to be configured: the files folder, which contains all of the files, images, cache, and other data, and the settings.php file, which defines all of the database access information. As a result, you will need to duplicate the model from the default.settings.php file located inside the sites/default folder and rename it to settings.php inside each of your multi-site folders. Within each folder, you will next create a files folder.

Drupal With Lando

  • Allow the /files and settings.php directories to exist after each site folder has been created.
chmod a+w settings.php
chmod a+w files
  • We can now begin installing each of our Drupal Multi-sites since we have all the required files. To prevent any surprises, we should run the following tasks in this order:
lando start
lando composer install
lando rebuild
lando info
  • We will make sure that Lando boots properly by using the configuration we have specified in the.lando.yml configuration file with the “lando start” command.
  • Since there will be missing main folders like Vendor in the files, the command “lando composer install” will begin downloading the remaining dependencies needed to install our Drupal.
  • The command “lando rebuild” examines the application in general. After Composer has finished downloading the files, the command should display the various URLs that are accessible for each of the several sites on the screen.

Drupal With Lando

  • You will be directed to the Drupal install page when you click on any of the aforementioned site URLs.

Drupal With Lando

Create Multi-Site In Drupal With Lando

  • We may verify database access information, including user names and passwords, with the use of the “lando info” command.
  • After completing the previous instructions, we can start installing each multi-site by writing the corresponding domain that we have specified in the lando configuration file and verified by running the “lando info” command. Recall that the database server’s localhost must be changed to the one that shows in the terminal if you install Drupal via Lando.

Create Multi-Site In Drupal With Lando

  • Your multi-site installation is now complete. You can use the following to access databases across several sites:
  • Here, after lando starts, the site URL created above is accepted by -uri. You can now continue working on your many sites and access their database.

Create Multi-Site In Drupal With Lando

Conclusion

We hope that through this post you were able to learn how to integrate Drupal with Lando, Moreover, if you are looking to hire dedicated Drupal developers who can assist you in managing your development, then you should check out Appic Softwares.

We have experienced and pre-vetted Drupal developers who will assist you with its development and maintenance.

So, what are you waiting for? Hire us now!

Get Free Consultation Now!


    Contact Us

    Consult us today to develop your application.

      Get in touch with us


      Skype Whatsapp Gmail Phone