Setting up a WordPress Development Environment in 5 Minutes

WordPress is famous for the 5 minute install. But setting up a local WordPress development environment is not as fun. There are tons of different options to choose.

You’ve got MAMP, Vagrant, WAMP, XAMPP, and the list goes on. I’ve covered setting up Vagrant before, but try taking a local meet up group through that setup process and see if anything breaks. Hint: It will.

Even GUI’d local development environments like MAMP can run users through a ringer with a misstep during setup. Want to install the WP-CLI too? It’s doable, but one slip-up will have you bug chasing for hours.

Developing WordPress with Docker

Docker is a software container platform. What is that? It’s a fancy way of saying Docker let’s you easily create specific local development environments to fit your application needs.

Docker automates the repetitive tasks of setting up and configuring development environments so that developers can focus on what matters: building great software.

That sounds confusing. But the thing about developing WordPress with Docker is that it allows others much smarter than ourselves to do the bulk of the leg work. All we need to do is know where to look.

WP Local Docker by 10up

10up | finely crafted websites and tools, one of the leading WordPress development companies, did a lot of that leg work for us with their WP Local Docker tool.

The repository comes with everything you need to easily spin up a Docker container for WordPress. No confusing Docker configuration needed on your end. You just need docker-compose and Docker. So let’s jump back a step and get those.

Installing Docker and docker-compose

The dreaded installation phase of installing a local environment. This is where things always go wrong. Surely Docker will be hard as well.

Nope. Just download the community edition for Mac or Windows, and well that’s it.

But installing the docker-compose command that’s where the real problems will come in.

Nope. It’s included in the download above. You’re good. Just install it and turn it on.

Setting up WP Local Docker

Now is the fun part. We get to use Terminal or whatever the Windows equivalent is. I don’t know. It’s been awhile since I’ve used PC, sorry.

First, you’ll want to navigate to a directory where you store all your project files. I prefer to use ~/Sites. But you’re welcome to use whatever folder you want. For the sites folder running cd ~/Sites should get you there.

Next you’ll run git clone https://github.com/10up/wp-local-docker.git <my-project-name> replacing <my-project-name> with the directory you’d like to create for your new WordPress install.

Once the git repository has finished cloning you’ll need to navigate to that directory within Terminal. Run cd <my-project-name> and you’re there.

Now for the magic. Run docker-compose up and Docker will start building out your fancy new WordPress local environment.

Docker Compose terminal

There isn’t a grand finale in the terminal saying the process has completed. Terminal will just stop spitting out new information in the tab. At that point pop open a new Terminal tab with CMD+T and run sh bin/setup.sh.

This runs the WordPress setup shell command included in the WP Local Docker repository to handle all of the WordPress database and installation setup for you.

Once that is done you can point your browser to http://localhost and you should see a brand new WordPress installation. Ready to be hacked to your heart’s content.

If you want to start a new site simply hit CTRL+C on the terminal tab we ran docker-compose up on. And clone the WP Local Docker repository to a new directory repeat the steps above and you’re good to go.

Building From There

Now that you have a local WordPress development site setup you can start playing around with theme and plugin development with no fear of taking your site down.

Check out the WP Local Docker repository for more tips like setting up SSH Access and the WP-CLI and really unleash the power of WordPress.

And from here you can start playing with your own Docker container settings. Enjoy.