Starting up a new Statamic site with Lando, Part 1
Tags: php, lando, docker, statamic
Published: 2021-03-05 04:54:34

<span>Photo by <a href="https://unsplash.com/@lazycreekimages?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Michael Dziedzic</a> on <a href="https://unsplash.com/s/photos/static?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>

# Why Stamatic?
I have been meaning to rework my website for several years, but other projects have always gotten in the way. I was waffling between a Laravel custom site, Wordpress, flat file sites, others.. you get the idea. That was also not helping with the spinning of wheels and getting nowhere.

When Laravel News [announced that they had updated their site to using Statamic 3](https://laravel-news.com/why-did-you-choose-statamic), I looked into the platform in more depth. (They also have a really cool write-up from the team that helped migrate them from Wordpress to Statamic [here](https://zaengle.com/blog/laravel-news-website))

Please come along on the ride with me as I try to boot this thing up and rebuild my website with Stamatic.

# Lando
Another tool I had recently learned about is [Lando](https://lando.dev), which is a very simple Docker-based site configuration tool that makes spinning up new web development projects super easy. Docker makes everything easier to develop and release since it is all self contained, and Lando takes a lot of the initial overhead of Docker container setup out of the equation. It even handles the creation and management of HTTPS certs, so you can develop securely on your localhost right out of the box. I highly urge you to check it out.

# Getting Started
## Install Lando
Step 1 is to [install Lando](https://docs.lando.dev/basics/installation.html#system-requirements) which varies depending on your operating system. On Linux, you can follow their [simple four step process](https://docs.lando.dev/basics/installation.html#linux) which includes installing Docker Community Edition. The Windows installer includes Docker Desktop, as well.

> After you have installed, verify your installation by attempting to use the `lando version` command -- which should print out the current version installed.

## Create your Lando + Statamic Project
The beauty of Docker (and Lando) is that you don't have to have any of your dependencies installed on your local machine, you can use the containers to do everything for you. Lando makes this super simple. Without composer installed locally, we can install the Statamic installer and start up a new application folder with a few commands.

```bash
$ mkdir my-cool-project
$ cd my-cool-project
$ lando init \
> --source cwd \
> --recipe lamp \
> --webroot public \
> --name my-statamic-site
```

It will create the `.lando.yml` file for you:
```yml
name: my-statamic-site
recipe: lamp
config:
  webroot: public
```
Lando comes with several [recipes](https://docs.lando.dev/config/recipes.html) out of the box, and LAMP, LEMP, or even the Laravel recipe will work (if you install Statamic's Laravel package). For this tutorial, I chose the LAMP stack.

### Configure Services (Optional)
I did not configure much at this point, but before building your images and containers, now is a great time to check out the Lando documentation to see the [additional services](https://docs.lando.dev/config/services.html) and configuration you can add to your project. Statamic doesn't require anything beyond the LAMP recipe's defaults.
Each recipe has it's own [available options](https://docs.lando.dev/config/recipes.html#config), so make sure to read through the available configuration for the one you choose.

## Install Statamic
From the base Lando configuration, we can use the composer image to install Statamic (from your newly created project directory):

```bash
$ lando ssh -c "composer global require statamic/cli && statamic new placeholder"
```
*NOTE* I was unable to figure out how to install statamic into the current directory, so we're installing it into `placeholder` and then we'll move everything up to our root directory afterwards.

After it's installed everything, move the project files up a directory (frustrating, but if you actually do want to keep this directory, you can just use that instead of the placeholder name -- just make sure to update your webroot in the `.lando.yml` above):
```bash
$ cd placeholder
$ mv * .* ..
$ cd ..
$ rm -rf placeholder
```
## Booting it up for first run!
You now have Lando configured, which will take care of your technology stack, and you have installed Statamic which is the software we will be using to build the site!

Let's turn it on! From our working directory, type the following command:

```bash
$ lando start
```

This will build all the Docker containers and images and get everything up and running. At the end, Lando will provide URLs where you can access your new shiny website!

```
   ___                      __        __        __     __        ______
  / _ )___  ___  __ _  ___ / /  ___ _/ /_____ _/ /__ _/ /_____ _/ / / /
 / _  / _ \/ _ \/  ' \(_-</ _ \/ _ `/  '_/ _ `/ / _ `/  '_/ _ `/_/_/_/ 
/____/\___/\___/_/_/_/___/_//_/\_,_/_/\_\\_,_/_/\_,_/_/\_\\_,_(_|_|_)  
                                                                       

Your app has started up correctly.
Here are some vitals:

 NAME                  statamic                             
 LOCATION              /home/<your_user>/workspace/statamic      
 SERVICES              appserver, database 
 APPSERVER_NGINX URLS  https://localhost:49155              
                       http://localhost:49156               
                       http://statamic.lndo.site/           
                       https://statamic.lndo.site/          
```

Now your new site is up and running with only a few commands!

![Your new site is up and running with only a few commands!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/md3y6k5irm62udn1np50.png)

## Create your admin user

The final step is to make your super user and get started on the control panel. Make sure you choose `yes` when asked if you want your user to be a super user!

```bash
$ lando php please make:user

Email:
 > youremail@yourdomain.com

 Name []:
 > John Smith

 Password (Your input will be hidden):
 > 

 Super user (yes/no) [no]:
 > y

User created successfully.
```
# Wrap Up
In this post, I went over how to install Lando to get a really quick LAMP or LEMP stack up and running and also installed Statamic! As I work more on building my new website, I will update with Part 2 -- which will include basic content creation and a little bit of tinkering with the layout and theme.