Back to Blog
PHP Development

Mezzio app development in WSL2

Steps

  1. Make sure WSL2 is installed on your machine, following the WSL2 installation guide.

  2. Install Ubuntu 20.04 LTS inside WSL2, as described in the Ubuntu 20 setup guide (the current version of this guide covers AlmaLinux 9, the distro the WSL setup has since moved to).

  3. Create a virtual host for your project using the virtual hosts guide.

  4. Using your terminal, move into the virtual host directory you just created:

    cd /home/your-username/projects/your-virtualhost
    

Install Dotkernel API by following the Dotkernel API guide. Make sure the data and log directories are writable by changing their permissions, as described in the common permission issues guide. 5. Set up PHPStorm to work with WSL2 files, as described in the JetBrains WSL development environment article.

Note

There is a guide for AlmaLinux 8 as well, but it is not fully functional because of a well-known issue regarding running systemd inside WSL2.

Frequently Asked Questions

What does this guide help you accomplish? +

It walks you through installing a Mezzio application (Dotkernel API) using WSL2 and running it on Ubuntu 20.04 LTS.

What do you need before installing Ubuntu inside WSL2? +

You first need WSL2 installed on your machine, which you can set up by following the linked WSL2 installation guide, before installing Ubuntu inside it.

How do you set up a virtual host for the project? +

After Ubuntu is installed inside WSL2, you create a virtual host for your project by following the linked virtual-host creation guide.

How do you install Dotkernel API once the virtual host is ready? +

Using your terminal, move into the virtual host directory you created (for example, `cd /home/your-username/projects/your-virtualhost`), then install Dotkernel API by following its guide. Afterward, make sure the `data` and `log` directories are writable by changing their permissions, as described in the linked permission-fix guide.

How do you get PHPStorm to work with the WSL2 project files? +

You set up PHPStorm to work with WSL2 files by following the linked JetBrains article on using a WSL development environment in the product.

Does this guide also work for AlmaLinux instead of Ubuntu? +

There is a guide for AlmaLinux 8 as well, but it is not fully functional because of a well-known issue regarding running systemd inside WSL2.