Local environment setup with Lando & Drupal

ByKarthik Kumar D Kon9th Jul 2021, 2022-12-01T08:00:00+05:30
Read Article
Local environment setup with Lando & Drupal

We developers always choose to have some tools or setup, which makes our lives easier during the development process whether it might be a local environment or higher environments. Not only will lives be easier with such a setup, even the productivity of the individual or team will be increased. And today we are gonna see how Lando will help the drupal developer or drupal development much more quicker and easier.

Lando is a development tool, it's a free, open source, cross-platform, local development environment and DevOps tool built on Docker (opens new window) container technology and developed by Tandem. Designed to work with most major languages, frameworks and services, This is a brief about Lando.

Now let's see how we set up Drupal 9 locally with Lando.

Initially you have to install Lando on your machine (I’m using Ubuntu).

$ wget https://files.devwithlando.io/lando-stable.deb
$ sudo dpkg -i lando-stable.deb
$ lando

After successful installation, when you type lando in terminal and hit enter, you will see commands listed which lando provides by default.

Let's proceed with the Drupal 9 installation.

$ lando init
--source remote
--remote-url https://ftp.drupal.org/files/projects/drupal-9.2.0.tar.gz
--remote-options="--strip-components 1"
--recipe drupal9
--webroot .
--name drupal9-local

This will download the drupal 9.2.0 version and place it in the drupal9-local folder. Further start lando by using the below command.

$ lando start

This will start the Drupal 9 installation and you will get the drupal up & running. And you can see the information in the instance running by using the below command.

$ lando info


You can modify or maintain the configurations in a file named .lando.yml, which can have the details of the php, mysql, nginx etc details. An example file is shown below.

$ nano .lando.yml
recipe: drupal9
    php: '7.4'
    composer_version: '1.10.1'
    via: nginx
    database: mysql:5.7
    webroot: .
    drush: false
    xdebug: true
        database: config/db.cnf
        php: config/php.ini
        server: config/server.conf
        vhosts: config/default.conf
        - composer install
        service: appserver
            DRUSH_OPTIONS_URI: "https://drupal9-local.site"

Also you can utilize lando utility to run the composer and other services defined in the config file. Few example commands are shown below.

$ lando composer require drush/drush
$ lando -v db-import -h drupal9 backup.sql.gz
$ lando composer test
$ lando mysql
$ lando php -m

This way by using lando you can set up drupal 9 on your local environment. And on the configuration front you can do many other things like configuring multisite, environment variables etc.

We Need Your Consent
By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance your site navigation experience.
I Accept Cookies