Using DevilBox for WordPress Development on WSL2 on Windows

Or: pretending I’m still a *nix wizard.

It’s been a while since I moved from MacOS back to Windows, and it’s also been a while since I worked on any WordPress sites.

I like Sage. Unfortunately, both Lando and Laragon are not supported scenarios, and so I went back to the Devilbox, which I used almost all throughout my Mac OS X/macOS days. Fortunately, the Devilbox is well-supported on WSL2. Here’s my set-up process.

WSL

Our starting point is WSL, or more specifically, WSL2. You need to be running at least Windows 10 version 2004, or Windows 11.

To install WSL2, type the following into PowerShell or the Windows command prompt with administrator privileges.

wsl --install

This will take care of installing all necessary dependencies etc. It will also install the Ubuntu distribution. I recommend sticking with it. In case you prefer a non-Debian based distribution, some of the commands will be different.

Update your Ubuntu installation.

sudo apt update
sudo apt upgrade

Docker Desktop

Next, you want the Windows version of Docker Desktop.

I recommend using winget, but of course you can download and execute the installer.

Run the following in PowerShell or cmd on your Windows host.

winget install Docker.DockerDesktop

Start Docker Desktop after the installation is done. It should have WSL2 integration automatically enabled.

The Devilbox

Now we’ve come to the meat of the whole process. Back to the Ubuntu command line. It’s as simple as cloning the GitHub repository.

git clone https://github.com/cytopia/devilbox.git

After that, it’s just a few more steps to get it up.

cd devilbox/ # that's the repository we just cloned
git checkout release/v3.0.0-beta-0.4 # I recommend using the v3 beta branch as it has a lot of nice QOL changes
cp env-example .env # default configuration should work
docker-compose up # start it up!

The config defaults in env-example should work just fine. You may need to adjust the following variables (see documentation):

  • NEW_UID
  • NEW_GID

And that’s it, your DevilBox instance is up and running.

The Devil is in the Details

There are some CLI tools pre-installed in the DevilBox. The relevant ones for me are wp-cli, composer and npm, so I like to update them. To do so, go to the directory the DevilBox is cloned to, and do the following:

sh shell.sh # enter the PHP container
sudo wp cli update # update WP-CLI to the latest version
sudo composer self-update # update PHP Composer
npm -g install npm@latest # update NPM to the latest version
npm -g upgrade # update all other NPM packages

All Systems Go

Now we are ready to create our first WordPress site!

In your browser, go to localhost or dvl.to, and you should see the following:

Click on Virtual Hosts, and you should see the following:

Go back to the command line. I’m going to assume you are still in the PHP container. Make sure you are in the /shared/httpd directory.

I’m going to create a site named widgetsco.

Execute the following to create the directories you need:

mkdir -p widgetsco/htdocs

Refresh the Virtual Hosts page, and you’ll notice that a site has been automagically created.

You’ll also notice a URL is automatically wired up, in my case it’s widgetsco.dvl.to. No need to edit your hosts file. One of the DevilBox 3.0 QOL improvements.

Now change directory to the directory we created just now, and then use the WP-CLI to get the latest stable, and :

cd widgetsco/htdocs
wp core download # install WordPress files
mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE widgetsco;' # default MySQL root user password is blank, so just hit "enter" when asked for one!

In the MariaDB CLI:

CREATE DATABASE widgetsco;

Now open your browser to http://widgetsco.dvl.to, and start the WordPress installation process.

And that’s it. A working WordPress site.


Posted

in

by

Tags:

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.