{"id":59458,"date":"2023-12-04T16:31:38","date_gmt":"2023-12-04T11:01:38","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=59458"},"modified":"2023-12-06T12:45:31","modified_gmt":"2023-12-06T07:15:31","slug":"multi-site-in-drupal-with-lando","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/multi-site-in-drupal-with-lando\/","title":{"rendered":"Multi-Site in Drupal with lando"},"content":{"rendered":"<p>In this article, we will learn a step-by-step process to set up Drupal multi-site, with a shared (single) codebase and a separate database per site on a local machine, using Lando.<\/p>\n<h2 id=\"3f86\" class=\"mz na ev be nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw bj\">\u00a0When to consider multi-site?<\/h2>\n<ul>\n<li id=\"fdaf\" class=\"pw-post-body-paragraph ly lz ev ma b mb nx md me mf ny mh mi mj nz ml mm mn oa mp mq mr ob mt mu mv eo bj\">Before we dive into the technical details about setting up multi-site, let us first understand when to consider multi-site setup.<\/li>\n<li id=\"0010\" class=\"pw-post-body-paragraph ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv eo bj\">The below-mentioned Pros &amp; Cons and the reasons given will help you decide whether multi-site is suitable for your sites or not.<\/li>\n<\/ul>\n<h3 id=\"a267\" class=\"pw-post-body-paragraph ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv eo bj\"><strong class=\"ma ew\">\u00a0Pros:<\/strong><\/h3>\n<ul class=\"\">\n<li id=\"2d04\" class=\"ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv oc mx my bj\" data-selectable-paragraph=\"\">Easy to maintain:<\/li>\n<li id=\"a419\" class=\"ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv oc mx my bj\" data-selectable-paragraph=\"\">Less development cost:<\/li>\n<li id=\"be8a\" class=\"ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv oc mx my bj\" data-selectable-paragraph=\"\">Have separate themes and features for each site:<\/li>\n<\/ul>\n<h3 id=\"7bf6\" class=\"pw-post-body-paragraph ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv eo bj\"><strong class=\"ma ew\">\u00a0Cons:<\/strong><\/h3>\n<ul>\n<li id=\"13f2\" class=\"ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv oc mx my bj\" data-selectable-paragraph=\"\">Single point of failure:<\/li>\n<li id=\"2789\" class=\"ly lz ev ma b mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv oc mx my bj\" data-selectable-paragraph=\"\">Site traffic management:<\/li>\n<\/ul>\n<p><em>Please note that we are not going to cover instructions to install lando. Please see the official Lando document for details.<\/em><\/p>\n<h2>Let&#8217;s start with setting up a multi-site with lando<\/h2>\n<p><strong>Step 1 &#8211;<\/strong> Configuring the .lando.yml file<\/p>\n<ul>\n<li>Lando works with a configuration file, allowing us to start different services so that our application works correctly. By default, in a normal Drupal installation, we would only have to run the lando init command, and this configuration file would be generated with everything necessary to run lando and Drupal without problems.<\/li>\n<li>However, in the case of a Drupal Multi-site installation, we will have to create our configuration file for lando and modify it according to our needs; for example, the URLs for our sub-domains, the access data for each database, etc.<\/li>\n<li>Although you can add many other configurations in a project of this type, below I will give you the basic file, with an explanation of each important section, so you can start several Drupal sites with Lando. Go to the folder where you have downloaded the Drupal Base files, then create a file called .lando.yml with the following code:<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59445 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-14-25.png\" alt=\"\" width=\"729\" height=\"954\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-14-25.png 729w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-14-25-229x300.png 229w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-14-25-624x817.png 624w\" sizes=\"(max-width: 729px) 100vw, 729px\" \/><\/p>\n<p>Explanation:<\/p>\n<ul>\n<li>In the first part of the configuration file, in addition to the project name, we have the main configurations, related to the web root.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59446 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-42-29.png\" alt=\"\" width=\"667\" height=\"215\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-42-29.png 667w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-42-29-300x97.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-42-29-624x201.png 624w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/p>\n<ul>\n<li>In the Proxy section, we will define the different domains for our Drupal sites;\u00a0the main name must correspond to their respective installation folder, just as happens in a Drupal Multi-site installation traditional.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59447 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-20-56.png\" alt=\"\" width=\"423\" height=\"115\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-20-56.png 423w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-20-56-300x82.png 300w\" sizes=\"(max-width: 423px) 100vw, 423px\" \/><\/p>\n<ul>\n<li>The last part of the configuration file is where we will define all the data related to our databases. Remember that you can confirm all the information, once Lando is started, using the information command:<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59448 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-21-33.png\" alt=\"\" width=\"512\" height=\"678\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-21-33.png 512w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-21-33-227x300.png 227w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/p>\n<p><strong>Step 2 &#8211;<\/strong> Setting up the main Drupal and multi-sites<\/p>\n<p>At this point, before starting our Drupal project, we will have to make several adjustments:<\/p>\n<ul>\n<li>Rename the file example.sites.php and leave it as sites.php, inside we will have to add the different domains and the folders to which each of them will point.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59449 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-49-43.png\" alt=\"\" width=\"404\" height=\"287\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-49-43.png 404w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-49-43-300x213.png 300w\" sizes=\"(max-width: 404px) 100vw, 404px\" \/><\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59450 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-51-32.png\" alt=\"\" width=\"765\" height=\"498\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-51-32.png 765w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-51-32-300x195.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-51-32-624x406.png 624w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/p>\n<ul>\n<li>Create the folders that correspond to the names of the domains that you have declared in the configuration file. The name of the folders must match both the name you have put in the lando configuration file and in the sites.php in the previous image.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59451 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-52-42.png\" alt=\"\" width=\"403\" height=\"325\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-52-42.png 403w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-52-42-300x242.png 300w\" sizes=\"(max-width: 403px) 100vw, 403px\" \/><\/p>\n<ul>\n<li>Add configuration files to multi-sites. Every Drupal installation requires at least two files for its configuration: the file where all the access data to your database will be defined, called settings.php, and the files folder, where it will house all the files, images, cache, etc. .<br \/>\nSo you will have to copy the model from the default.settings.php file that is inside the sites\/default folder, and once inside each folder of your multi-sites, rename it to settings.php. Next you will create a files folder inside each folder.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59452 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-55-19.png\" alt=\"\" width=\"391\" height=\"292\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-55-19.png 391w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-22-55-19-300x224.png 300w\" sizes=\"(max-width: 391px) 100vw, 391px\" \/><\/p>\n<ul>\n<li>After creating each site folder, let&#8217;s permit the settings.php and \/files directory.<\/li>\n<\/ul>\n<pre><em>\u00a0 \u00a0 \u00a0 \u00a0 <strong>  chmod a+w settings.php<\/strong><\/em>\r\n<strong><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0chmod a+w files<\/em><\/strong><\/pre>\n<ul>\n<li>Since we have all the necessary files to start installing each of our Drupal Multi-sites, we should execute the following commands in this order to avoid surprises:<\/li>\n<\/ul>\n<pre><em><strong>    lando start\r\n    lando composer install\r\n    lando rebuild\r\n    lando info<\/strong>\r\n<\/em><\/pre>\n<ul>\n<li>With the &#8220;lando start&#8221; command, we will ensure that Lando boots correctly, using the configuration we have defined in the .lando.yml configuration file.<\/li>\n<li>The command &#8220;lando composer install&#8221; will start downloading the rest of the necessary dependencies to install our Drupal, since within the files, we will be missing main folders such as Vendor.<\/li>\n<li>The &#8220;lando rebuild&#8221; command performs a general review of the application. Once the files have been downloaded with Composer, at the end of the execution, the command should show us on the screen the different URLs available for each of the Multi-sites.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59453 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-06-26.png\" alt=\"\" width=\"640\" height=\"288\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-06-26.png 640w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-06-26-300x135.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-06-26-624x281.png 624w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>While clicking on the above site URLs, it will take you to the drupal install page.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59455 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44-1024x543.png\" alt=\"\" width=\"625\" height=\"331\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44-1024x543.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44-300x159.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44-768x407.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44-624x331.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-15-44.png 1148w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59456 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-1024x348.png\" alt=\"\" width=\"625\" height=\"212\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-1024x348.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-300x102.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-768x261.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-1536x522.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08-624x212.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-18-08.png 1674w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<ul>\n<li>The &#8220;lando info&#8221; command will help us confirm the access data to the databases, with their respective users and passwords.<\/li>\n<li>Once all the previous commands have been executed, we can begin the installation process of each of the multi-sites, writing the corresponding domain, which we have defined in the lando configuration file and which we confirm by executing the &#8220;lando info&#8221; command. Remember, if you install Drupal using Lando, you must change the localhost of the database server to the one that appears in the console.<\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-59454 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-14-00.png\" alt=\"\" width=\"712\" height=\"98\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-14-00.png 712w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-14-00-300x41.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-03-23-14-00-624x86.png 624w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>Finally your multi-sites are successfully installed. For multi-sites DB access, you can use:<\/li>\n<\/ul>\n<pre><em>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 lando drush sql:cli --uri=http:\/\/site1.lndo.site:8080\/\u00a0<\/em><\/pre>\n<ul>\n<li>Here &#8211;uri accepts the site URL created above after <em>lando start. Now you can access their DB &amp; continue to work on your multi-sites.<\/em><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59457 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-36-59.png\" alt=\"\" width=\"520\" height=\"191\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-36-59.png 520w, \/blog\/wp-ttn-blog\/uploads\/2023\/12\/Screenshot-from-2023-12-04-13-36-59-300x110.png 300w\" sizes=\"(max-width: 520px) 100vw, 520px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Throughout this blog, we delved into crucial aspects, gaining insights into fundamental site configurations and harnessing the power of Lando for seamless development. This newfound knowledge empowers us to establish robust Drupal sites and serves as a foundation for future endeavors. As we conclude this blog, let&#8217;s celebrate the accomplishment of mastering basic site and Lando configurations, paving the way for more efficient and streamlined Drupal development experiences.<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>In this article, we will learn a step-by-step process to set up Drupal multi-site, with a shared (single) codebase and a separate database per site on a local machine, using Lando. \u00a0When to consider multi-site? Before we dive into the technical details about setting up multi-site, let us first understand when to consider multi-site setup. [&hellip;]<\/p>\n","protected":false},"author":1525,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":174},"categories":[3602],"tags":[4862,5563],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59458"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1525"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=59458"}],"version-history":[{"count":6,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59458\/revisions"}],"predecessor-version":[{"id":59481,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59458\/revisions\/59481"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=59458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=59458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=59458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}