Install and Configure Lando for WordPress

Install and Configure Lando for local development of WordPress sites.

Discuss in our Forum Discuss in Slack
Author photo

This guide will help you get up and running with Lando, an Open Source development tool intended for developers who prefer a painless, easily customizable local server environment configuration they can track in their source control repositories.

Try Localdev

Pantheon has been building our own local development tool! Localdev is built using Lando, has a friendly GUI, and is great for WordPress and Drupal sites. Click above to try it out, or check out the docs.

Before You Begin

Be sure that you have:

Installing Lando is straight forward. Be sure to check its system requirements to ensure you can proceed. Note that Lando does not currently provide a Graphical User Interface (GUI). Everything is managed from the command line.

Download and Install Lando

  1. Download the appropriate Lando release for your Operating System.

  2. Click to open the installer package. The installer has a few pre-flight checks it runs before getting started.

    Image of the Lando installer

Once you finish following any system prompts, the Lando installation script will work its magic and install itself on your computer.

Getting Started

You’ll manage your Lando instances via the command-line. A short list of useful Lando commands can be found here. If you ever need a refresher, simply pull up your terminal and type:

lando --help

The Lando command is installed globally so you can run it from anywhere within your terminal.

 Note

It’s always a good idea to keep your project's site files and folders organized. Keep your website projects in separate folders from one another.

Create a separate folder to hold your Lando-powered installations rather than mixing with installs managed by other server environments.

Install WordPress Locally

Getting started with Lando can be disorienting at first. Fear not, mighty developer, that’s why this documentation exists! We’ll begin by installing and spinning up a fresh WordPress site locally, without Pantheon integration.

Note that you can follow these same basic steps with an existing Pantheon Drupal site, just replace the starting recipe.

  1. Open your terminal and get to the directory where you plan to run your fancy Lando WP site:

    cd ~/projects/my-wp-site
  2. Initialize the lando site:

    lando init
  3. You may choose to start from your current directory or you can clone from Pantheon, Github, or another remote repository, or zip file. For this step, we’ll choose current working directory.

  4. Next, you’ll choose WordPress as your starting recipe.

    Choose your Lando recipe to spin up a new website.

  5. For your webroot, you may press enter and Lando will spin up the site from your current directory.

  6. Enter the name of the site. Use something you’ll remember!

    Your local site has been created but you're still not done! You still need to start the app, download WordPress and then install WordPress. Sure, it’s a few steps but the command-line practice is good for bone growth and keyboard-punching-dexterity.

  7. Start Lando:

    lando start

    This starts your Lando app and gives you some basic information like your Appserver URLs to access the site in your local browser of choice:

    alt text

  8. Download the WordPress Core:

    lando wp core download

    This command downloads the current stable release of WordPress and unpacks it in your current working directory. This step isn’t necessary if you started with a Git or Pantheon repository instead of the current working directory.

     Note

    This is where we talk a little bit about WP-CLI, Lando, and You. To use WP-CLI commands in Lando, simply prefix your wp command with lando and you’re good to go, Lando will run your WP-CLI command all nice like.

  9. Your WP configuration file still needs to be created. You can actually do this from the command-line. However, we’re going to go to do this the ol’ fashioned way through the browser.

  10. In your browser, enter in the URL given to you above: http://yourappname.lndo.site. You’ll notice WordPress’s Famous Five Minute install screen.

  11. Click next after choosing your preferred language and click let’s go on the following screen.

  12. In Lando, for a WordPress installation without Pantheon, the Database, Username, and Password are all wordpress and Database Host is database (all values are case-sensitive). Enter your credentials and complete the installation process.

Congrats! You now have Lando installed with WordPress!

 Note

You can find your site’s login details simply by typing lando info in your terminal.

Installing WordPress Using the Pantheon Recipe

Using Lando with Pantheon provides a few key advantages:

  • It closely mimics Pantheon’s tech stacks and environments for your local environment, getting you as close to a one-to-one development setup as possible.

  • The recipe also installs Terminus (if you don’t already have it installed), Pantheon’s powerful web server management CLI.

  • And if that wasn’t enough, you can push and pull changes directly into Lando from any of your Pantheon environments.

To use this Lando recipe you must have:

  1. From the directory of the WordPress site created in the section above, stop the Lando instance (if still running):

    lando stop
  2. In your project directory, create a new directory for your WordPress + Pantheon integrated environment, and cd to it.

  3. Initiate a new Lando site, specifying Pantheon as the source:

    lando init --source pantheon

    The only difference between this and lando init is that defining the source as pantheon allows you to skip a couple of prompts.

  4. When prompted, paste in a Pantheon machine token you created for Lando. Note that most Terminal emulators use CTRL/Command + V to paste, and you will not see any characters added, * or otherwise.

  5. Choose the Pantheon site you want to pull from to create your local site.

     Note

    Lando creates your local environment, mirroring your dev environment closely, and then clones down the site’s codebase (this part of the process does not include media files in the uploads folder or the site’s database). This will take a few minutes or so depending on the site’s size.

  6. Once complete, you can run the site locally:

    lando start

With your site started, you’ll have your local site URL so you can access it from your browser. But now you can also pull the code, media files, and the database from the site’s Pantheon environment.

Pushing and Pulling Your Changes

Certainly, one of the most awesome benefits of using Lando with the Pantheon recipe is the ability to push your changes from your local site to your various Pantheon environments (including live and multidev instances).

To initiate a push from your local environment simply type lando push; conversely, type lando pull to perform a pull. Either action will have Lando prompt you for which environments you wish to pull/push your codebase, files, and database from or to.

 Note

Your database refers to your app's database. Your code refers to your app’s codebase. That is, any files that you would track within your site’s source control repository. Your media refers to assets and files stored within the /uploads folder; generally speaking, it’s a good idea to NOT include your media files in your repository as your repo’s size can get out of hand quickly.

From your terminal environment:

  1. Pull changes from Pantheon:

    lando pull
  2. For our purposes, you will choose dev but it’s important to note you can pull your files from any Pantheon environment, including multi-dev environments.

  3. For the next prompt, you’ll be asked where or if you want to pull the database. Again, choose dev.

  4. In the next prompt, again, choose dev for files.

Lando also runs a search and replace on the database siteurl and sitename table fields and replaces Pantheon’s values with your local values.

 Note

Sometimes, it’s a good idea to do your own search and replace on your local site once a pull has finished. Also, it can be a good idea to run a search replace on a site on Pantheon you pushed to. Here’s how you can do both!

lando wp search-replace 'yourpantheondevurl.com' 'yourlocalapp.lndo.site'

OR

terminus wp yourpantheonsitename.dev -- search-replace 'yourlocalapp.lndo.site' 'yourpantheondevurl.com'