Lokl

WordPress local development environment for Mac, Win & Linux

Secure. Fast. Free!

Getting started with Lokl

sh -c "$(curl -sSl 'https://lokl.dev/cli-5.0.0')"

Mounting volumes via site templates

From version 5.0.0, Lokl now supports site template files, which, if present, Lokl will allow you to choose as a template for your new site. They’re totally optional, Lokl runs just fine without them.

Currently, these allow specifying directories from your host machine to mount within your Lokl site’s container. This makes it easier for those editing plugins/themes/site files on their local computer and having the changes apply immediately within their Lokl site.

Future enhancements to this templating will allow for things like specifying different sets of plugins/themes to auto-install in new Lokl sites.

An example site template file is located within the lokl-cli GitHub repository, named site-template-example.lokl. There are comments in this template, describing how to use it, also described here:

ie, on macOS, this would be /Users/leon/.lokl/templates

Safety

Running arbitrary code on your computer is never safe.

You can verify this script’s contents/trust by:

You can also download the script and run it locally:

The copy-paste method of running scripts is still used by some major projects, such as Homebrew, RVM, Docker.

I like the ease of use of this method for new users, but I feel responsible to inform about the security considerations.

How it works

Lokl relies on the free Docker virtualization in order to create a small, containerized environment for each Lokl WordPress site you want to run.

The Lokl project contains several pieces that work together to provide a very easy way to create and maintain 100’s or 1,000’s of WordPress environments on your local computer:

Lokl Docker image

You may consider this to be a pre-built mini operating system, with WordPress built-in and a bunch of optimizations added.

Lokl Docker provisioning scripts

These take the pre-built Lokl Docker image and apply site-specific customizations, so that each site is independent and easily manageable via its unique name.

Lokl shell scripts

This is the entrypoint and main control point for Lokl. It’s the POSIX-compliant shell script available at https://lokl.dev/cli-5.0.0 or downloadable to run as a local script. This script provides you with an easy to use CLI (command line interface) wizard, that responds to your input and interacts with your WordPress container(s) in the background.

Requirements

Docker

As I describe how Lokl works above, Docker is a base requirement for Lokl to run. It is free to install on Lokl’s supported platforms:

Please note, that Lokl currently expects you to have Docker setup to accept commands as the current user, not with sudo privilege escalation, though I’ll try to get that more seamlessly supported in future.

cURL

I use this in the one-line launch wizard on the homepage, but also within Lokl’s behind the scenes scripts. It’s free, available by default in macOS and easily installable on all other environments.

It’s worth mentioning that cURL has been generously developed for years by Daniel Stenberg, along with many contributors. You may not be aware, but you’ll have run some software or websites in your life that benefit from cURL. Thanks Daniel!

If you need help installing cURL for your environment, please ask on my support forum.

supported shell environment

The main Lokl shell script is designed to be POSIX-compliant and compatible with the most common shells/terminals you are likely to be running. If you encounter an issue running Lokl in your funky shell, please file an issue.

FAQs

I’d strongly dissuade you! Lokl is designed for your local WordPress development environment and expects you to publish your live site using a static site generator for WordPress (I include the most common ones within Lokl for you).

Running WordPress locally and publishing a static site to production hits the three goals of security, cost and performance excellently. Lokl is designed for running WordPress on your own computer, comfortably isolated within its own container. This means I don’t need to waste time on the usual security measures one would want to implement and maintain on a publicly exposed WordPress site.

No(not yet), as Docker won’t run on them. If you have some cool hack to allow Docker to run on any of the BSDs, then it should work and I’d love to hear from you!

Update: I’ve created my own feature-request to get this working for my preferred OS, OpenBSD. The lokl-cli wizard should be able to drive vmm(8) in place of Docker and provide the same user experience, although this is a very small target audience, who usually have their own geeky ways to do things. If you’re a FreeBSD or other BSD user who wants to see it done via bhyve or such, reach out to me, would be fun to hack away on!

See the FAQ about why Lokl isn’t for running in production. TLS isn’t required for such locally contained web servers and would limit the portability and ease of use of Lokl if I was to bother with it.

Why do you need this? Lokl comes with built-in, name-based management of all your sites, which will be in the form of http://localhost:4123, with a unique port within the range of 4000-5000. This allows the super-simple one-line installation/management script to work without you needing to configure anything on your host operating system.

If you really needed to map a custom hostname locally to one of your Lokl sites, you can definitely do it yourself, via some creative proxying, but it’s not something I’m likely to want to help you with unless it would make sense for a lot of Lokl users.

Back to top