I already told you about Lando a while ago… it was more of a cry from the heart to have found a simple solution to use Docker technology.
What’s Lando?
As I explained in my previous article, Lando is an overlay that makes it easy to use Docker Technology.
To put it simply, you have to see Docker as a modular tool where each brick is the component of your web server.
So you will need for example, to run a WordPress locally an Apache brick, a PHP brick and a Mariadb or Mysql brick.
Among these different bricks, there are different versions. For example PHP7.0 / PHP7.3 .
To develop soundly and avoid unpleasant surprises during production, it can be interesting to use during our developments the same software versions as those used by the server that will host the website in the end. In this way we reduce the risks of conflicts and errors.
Docker’s goal is to provide these different bricks and make them work together… except that…
Except that, as I said in my previous article, you have to set all this up… and have sysadmin knowledge that we don’t all have… fortunately Lando has arrived…
Install Lando
The hardest part of installing Lando is actually installing Docker which is quite simple if you are free like me, i.e. on a Linux distribution. It’s a bit more complicated if you’re trapped in a private system such as Windows or Mac OS. (For once we have something simpler under Ubuntu Linux… )
In short, Docker runs natively under Linux, you’ll have to add a virtual machine to install Docker on Windows or Mac OS.
Once Docker is installed, go to Lando’s website to install the overlay that will set all this to music.
Configuring Lando
I told you earlier that Lando was ignoring the complexity of Docker’s parameterization.
All the configuration of your development server will fit in a text file.
Let’s imagine that we want to create a WordPress site with the url https://mon-super-site.lndo.site.
Just create a folder on your machine where you have the write access and that you would name with the name you want: my-super-site.
In this folder we will add a .lando.yml file that will contain all the configuration of the server of our site:
That’s it, that’s all! Lando is ready to go! And you’re ready to develop!
Let’s decorate the .lando.yml:
- Line 1: A name for your development environment. This name will be used to build the url of your project.
- Line 2: “Recipe” means recipe in English. Lando has developed preconfigurations according to what you will do with it. Here is a WordPress recipe, it will install wp-cli. There are some for Pantheon, Drupal and more => Lando Recipe
- Line 3: a config block where you can specify your software versions
- Line 7: a Service block where we will list the services we want to see working. here PhpMyadmin and Mailhog
- Line 16: Composing is still practical when working in the PHP world.
- Line 19: This block is optional if you are working on a simple domain. It can be very useful when working on a Multisite WordPress subdomain for example.
- Line 22: maybe the nicest part… do some tasks just after importing a database… here we do via wp-cli a search & replace to adapt the urls and we disable the excellent WordPress WP-Rocket extension because the cache in dev… how to say 😉
This .lando.yml is quite simple and there is a multitude of other configurations and possibilities to best fit your needs.
Note that Lando is oriented for development and is strongly discouraged by its developers for a production
To run Lando for the first time, you have to do a `lando rebuild –y’.
At this point, it will create and download what it needs. This step can be long depending on your web connection but it will only be done once…
Then for the next launches a `lando start` in your terminal in your working directory will be enough.
Attention the WordPress recipe prepares lando technically to receive WordPress but does not install WordPress. You will perform this installation step as you are used to or by using my wp-cli method.
I use Local By Flywheel… it’s the same thing!
Hummm each solution has its advantages and disadvantages. When I decided to test and finally adopt Lando, Local By Flywheel was not available under Linux. This is no longer the case since the summer of 2019.
I (too) quickly tested Local By Flywheel and I couldn’t get a WP to work :-/ (note it too much).The only thing Flywheel brings for my case is a GUI (Graphical User Interface) whereas Lando… it’s command-line… but sincerely to make lando start or `lando rebuild –y`? install an interface that will necessarily use machine resources… I didn’t see the point.
Hi,
I’ve tried your yaml configuration and it works perfectly. If you already have a working WordPress environment you need to:
1 backup your database using something like: lando db-export db-exports/`date +%F_%T`.sql
2 destroy your app: lando destroy -y
3 import your database: lando db-import db-exports/2020-04-14_23:13:14.sql.gz
4 start your app
I also have a question: lando’s documentation states that composer is already included with WordPress recipe (https://docs.lando.dev/config/wordpress.html#tooling), aren’t you installing composer twice?
Best regards!
Hi Mauricio,
Your right for the 1st part, but I started on the bases my readers don’nt know lando so will test on a new WordPress install.
About Composer, you’re right it works without
tooling:
composer:
service: appserver
But the lando rebuild send me errors on database link while the website is running well… so I’ve added it…
Hi Sebastian,
Thank you for this useful write-up. Any chance you know what the steps involved are to get Lando to work for an existing WP multisite with directory structure (not subdomain)? Do we list the directories line by line in ‘Proxy’, and how? Do we edit any other file? A WP file, htaccess file?
Thank you.
Hello Mark and thank you
I didn’t test on sudfolder 🙁 but the proxy is to reate different URL as a.example.com is a different domain than b.example.com when example.com/a is the same domain than example.com/b
Hi,
thank you for your post.
Were you able to configure a Lando NGINX recipe for a WordPress Multisite installation (with subfolder schema, not subdomains)?
If yes, may you share your code or leave me a breadcrumb? I am not able to accomplish this task.
My best
Hello Davide,
Thank you for commenting my blog post.
Unfortunately I never had to configure an nginx environment.
I’ve sent you an invitation to the Lando’s Slack, you’ll surely find help there.
Have a nice day
Hello,
has anyone here ever tried to use this command, into the lando recipe:
events:
post-db-import:
– appserver: wp plugin is-installed wp-rocket && wp plugin deactivate wp-rocket
I am getting an error unfortunately, and I suppose is about “is-istalled” or “is-active” option.
ERROR ==> message=, stack=Error
at /snapshot/lando/build/cli/lib/shell.js
From previous event:
at Shell.sh (/snapshot/lando/build/cli/lib/shell.js)
at Object.dc (/snapshot/lando/build/cli/lib/bootstrap.js)
at compose (/snapshot/lando/build/cli/lib/bootstrap.js)
Hello Davide,
Did you experience the same issue on your live website (without Lando ?)
hi
thanks for this tutorial
It would be very nice if we could have a step by step guide for setting a multisite
Hello and Thank you.
For a multisite in sub-domain or multi-domain, you just need to create some virtualhost in the “proxy” part of the
.lando.yml
example: