Today I'm going to detail how to install and run a Drupal 8 site on your local machine, and use either Lando or DDEV as the back-end. The same process should, in theory, work on a Mac and even in a WSL system on Windows 10 (you will need the Pro version, though), but ymmv.

First thing to do is get the required tools installed:

Docker: https://docs.docker.com/install/linux/docker-ce/ubuntu/ Composer: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
Lando: https://docs.devwithlando.io/installation/linux.html
DDEV: https://ddev.readthedocs.io/en/latest/#installationupgrade-script-linux-and-macos

Docker

If you have any issues, or need to install this for another operating system, I suggest checking the linked docs above.

  1. Update the apt package index:

    sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    
  3. Add Docker’s official GPG key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    sudo apt-key fingerprint 0EBFCD88   
    
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]
    
  4. Use the following command to set up the stable repository.

    sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
    
  5. Update the apt package index.

    sudo apt-get update
    
  6. Install the latest version of Docker CE and containerd, or go to the next step to install a specific version:

    sudo apt-get install docker-ce docker-ce-cli containerd.io
    
  7. Verify that Docker CE is installed correctly by running the hello-world image.

    sudo docker run hello-world
    

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits. If you see the message, you're good to go. If not, read the documentation I've linked to above to try figure out the problem.

Composer

Taken from https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos

  1. Download and run the composer installer. Note that you should already have PHP installed. If you need to do that, this page should help: https://www.php.net/manual/en/install.unix.php:

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    
  2. I recommend installing it so that it can be used globally throughout your system:

    mv composer.phar /usr/local/bin/composer
    
  3. You should be able to run composer in your terminal and see the help output.

Lando

Taken from https://docs.devwithlando.io/installation/linux.html

  1. Download the latest package file from GitHub.

  2. Run the installer:

    sudo dpkg -i lando-stable.deb
    
  3. If your distro uses a docker group, make sure your user is a member of it:

    sudo usermod -aG docker $USER
    

    You will need to log out for this change to take effect. Sometimes a reboot is necessary.

  4. Run lando in the terminal and you should see the default help output. If not, check out the linked documentation for more help.

DDEV

Taken from https://ddev.readthedocs.io/en/latest/#installationupgrade-script-linux-and-macos

  1. Run the following command to install DDEV:

    curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash
    
  2. On variants of Linux you may be prompted for additional package installation to get certutil installed, but you can follow the instructions given by mkcert:

    mkcert -install
    
  3. Run ddev in the terminal and you should see the help message. If not, check out the documentation for help.

Drupal

Taken from https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies

If you've made it this far - congrats! Hopefully you didn't have too many issues. Let's get Drupal installed now.

  1. Download Drupal with composer (change my_site_name_dir to the directory name you want to install Drupal into):

    composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction
    
  2. This will download the current dev version of the 'drupal-composer/drupal-project' project into a folder named 'mysitename_dir' and then automatically executes composer install which will download the latest stable version of Drupal 8 and all its dependencies.

  3. Now you get to choose your back-end system to run your site. You don't need both, although you could run both if you really wanted to.

Running Drupal on DDEV

(Scroll down for Lando instructions.)

  1. To use DDEV as your back-end, run the following command i your root folder and follow the prompts (it should auto-detect all the settings, but you might have to set a url-friendly project name):

    ddev config
    
  2. To start your database and web server containers run:

    ddev start
    
  3. It will take some time to download all the required bits and pieces, but when restarting later on, it will be much faster.

  4. If you get an error about port 443 being in use, edit .ddev/config/yaml and change these lines:

    router_http_port: "80"
    router_https_port: "443"
    

    to

    router_http_port: "8080"
    router_https_port: "8443"
    

    then run

    ddev start
    
  5. You can, in theory, use any port numbers you want, but these are fairly standard practice ones for local development.

  6. You should see the following message (or something similar) if everything worked properly:

    Successfully started my-site 
    Project can be reached at https://my-site.ddev.site:8443, https://127.0.0.1:32775
    
  7. Now go to https://my-site.ddev.site:8443 and you should see the Drupal install page.

Running Drupal on Lando

  1. Run lando init in the root folder of your site. The prompts don't seem to auto-detect all the settings, so I'll detail each option here.

  2. Select current working directory for the first option.

  3. Choose drupal8 for the recipe you want to use. If you plan to host on Pantheon, you can choose that as your recipe.

  4. For the webroot, enter web as that is the folder where your Drupal codebase is installed.

  5. Now run lando start to get things going.

  6. Lando installs faster than DDEV (at least on my system), and it generates seemingly random port numbers, so you shouldn't get any clashes with ports in use. You should see the following message is all goes well:

    BOOMSHAKALAKA!!!
    
    Your app has started up correctly.
    Here are some vitals:
    
    NAME            my-lando-app                       
    LOCATION        /var/www/html/my_site_name_dir     
    SERVICES        appserver, database                
    APPSERVER URLS  https://localhost:32790            
                    http://localhost:32791             
                    http://my-lando-app.lndo.site:8080 
                    https://my-lando-app.lndo.site:444
    
  7. Open up one of the provided urls in your browser and you should see the Drupal install screen. Note that the https urls wil give you warnings in Chrome and Firefox, but you're good to accept the risks and load the pages anyway. DDEV does not have this issue.

So there you have it. A good local dev setup for Drupal 8, using Docker's container system as the back-end - you get to choose which implementation you prefer. I've used both and don't really have a preference, tbh. Both work well and sites load quickly in each.

Lando does seem to be a bit faster to setup, and has some nice recipes to set things up e.g. for Pantheon. DDEV uses the standard ports for serving sites, and has a trusted root certificate (via the mkcert step), so you don't get warnings about https connections.