WordPress for Windows Development Guide with WSL

Home / Web development / WordPress for Windows Development Guide with WSL

If you need a WordPress for Windows development guide with WSL, you've come to the right place.

Several days ago I decided to install WSL on my Windows 10 computer and migrate my local XAMPP developments to this new environment. The reasons behind this decision are varied, but can be summarized in two:

  • WAMP/XAMPP are fine to start with, but many Linux tools are still far superior to those available to Windows users.
  • My local developments are getting heavier and slower.

It turns out that a few weeks ago a co-worker proposed to upgrade the development, staging and production servers to PHP version 7.4. Until now we were using version 7.3 and soon we will be using 7.4. official support will end. He also warned me that Windows has already will not officially support PHP version 8. And of course, for me this was not one drama, not two, not three, but three:

  1. On the one hand, because I am was an XAMPP user. And I switched to XAMPP because WAMP was a pain in the ass. But upgrading XAMPP, or one of its components, is quite a tedious task. It involves doing a thousand backups, throwing it all away, and putting it back together as you had it. And that's just for upgrading from PHP 7.3 to 7.4.
  2. On the other hand, because if I keep using XAMPP or WAMP or MAMP (for Windows xD), when it's time to upgrade to PHP 8 I'm going to look black, and I don't feel like it.
  3. And finally, because those who we use If you use WAMP/XAMPP, you will have noticed that the speed of the sites leaves a lot to be desired and degrades over time.

So, as I'm neither a Docker nor a virtual machine guy, I've decided to take the middle way: WSLWindows Subsystem for Linux.

WSL or Windows Subsystem for Linux

WSL is nothing more or less than a compatibility layer that allows you to run one or more Linux distributions on your Windows 10 computer.

At the time of writing, WSL has two versions (version 1 and version 2, easy). Each of these versions has a number of features that you can see in the following image:

As you can see, version 2 offers more "proper" Linux features and will be the reference version of this guide.

Therefore, WSL2 is going to use a real and complete Linux kernel that is updated through Windows Update. It also incorporates a drive mount system by which you can access your Windows hard drives from Linux and vice versa. This way, in addition to being able to run any Linux command on your computer, it also allows you to use its files together.

File system

One thing you need to understand very well is how the WSL file system works and its integration with the Windows file system.

When installing WSL, from Windows we will be able to access a network device that is in \\wsl$ and that's where the Linux distribution's file system is hosted.

In the same way, in the Linux distribution, each existing drive in our Windows system appears as a drive mounted in /mnt/

And finally, it should be noted that today WSL does not allow you to run applications with graphical interface (although there is a development in process to support). Therefore, WSL only works through console, so any file that we want to edit with a program installed in Windows must be in the Windows file system. Likewise, any file that we want to edit with a program installed on Linux, must be inside its file system.

However, most modern IDEs, such as PHPStorm or VSCode already support working with the WSL file system, so we won't notice any difference.

If you want to try unofficial options to use applications with graphical interface inside WSL, here you are this simple tutorial by Luis Henrique Demetrio in the Microsoft Tech Community. I've tried a couple of them, and I haven't been able to get it to work.

WordPress Development for Windows with WSL: The Ultimate Guide

I'm not going to get into the Windows VS Linux debate, nor the moral implications of all this that we're going to do. For me, honestly, it's a magical opportunity to bring together the best of both worlds that I plan to explore as far as I can. If you've read this far, I hope you've at least dropped a What the f...

DISCLAIMER: I just want to reiterate that this guide is oriented to WSL version 2 and working with WordPress and PHPStorm, although the basics can be used for any software running PHP and most modern IDEs.

As I don't want to make very long posts, because it takes me forever and I don't publish them, I'm going to publish a series of instalments about the process, which I'll link to as I publish them:

  1. WordPress Development for Windows with WSL (part 1): Installing WSL
  2. WordPress Development for Windows with WSL (part 2): Installing the LAMP Stack
  3. WordPress Development for Windows with WSL (part 3): Migrating a web site from XAMPP to WSL
  4. WordPress Development for Windows with WSL (part 4): Git, PHPStorm, xDebug and WP-CLI Integration
  5. COMING SOON: WordPress Development for Windows with WSL (part 5): Tools and Tricks to Increase Productivity

<i class="fa fa-angle-up" aria-hidden="true"></i>