How to Install and Use systemd to Manage Services in WSL
Windows Subsystem for Linux, or WSL, is a great way for developers who need to run Linux and Windows to do so without having to set up a virtual machine or dual boot.
One major new feature is the ability to run systemd on WSL, which is useful for web developers setting up test environments locally. Here’s how to enable and use it.

Why Install systemd on WSL?
WSL services by default run the older System V init service and services are started with the service command. In September 2022,Microsoftadded the option to use systemd to manage services. Most major Linux distributions have already changed to systemd.
Despite the controversy, in real use, it’s much simpler tostart and stop services with systemd. It’s also easier to follow along with other Linux tutorials as you don’t have to change around commands as much.

A local LAMP testing environment will be closer to a standard Linux server, so your app will be easier to debug.
How to Enable systemd on WSL
To enable systemd, you have to run the right version of WSL. systemd requires WSL version 0.67.6 or higher. you may check the version number by opening up PowerShell and typing:
If you have an older version installed and wish to use systemd, you’re able to update WSL using:

Now you’ll have to set up systemd in any distro you have installed with WSL. The process is the same on any WSL distro, whether that’s Ubuntu, Debian, Fedora, or something else.
Simply edit the/etc/wsl.conffile in your system as root and add these lines:

If the wsl.conf file doesn’t exist, don’t worry and proceed by creating it yourself. These lines will work regardless.
Save the file, and now you’ll have to restart any running WSL distros. To do this, open up a PowerShell window and type this command:

Open up another terminal, and you’ll be able to manage services with systemd on WSL.
Starting and Stopping WSL Services With systemd
You can now usesystemctlto start and stop services in WSL.
Suppose you were using Apache to run a local web server to test a web app you were developing.
You’d start Apache like this:
If you wanted it to start automatically, you’d enable it using:
And disable it with:
Now You Can Run systemd on WSL
With the latest updates to WSL, you could now enable systemd and start and stop services as you need them. This makes WSL a good environment for developing web applications, as you can test them as if you were using any other standard Linux machine.
It’s also extremely easy to install a LAMP (Linux, Apache, MySQL, PHP) server on Windows Subsystem for Linux.
Want to get started with web development on Windows Subsystem for Linux? Begin by setting up a LAMP test environment.
Tor spoiled me forever.
When your rival has to bail out your assistant.
My iPhone does it all, but I still need my dumb phone.
Flagship price, mid-range phone.
Free AI tools are legitimately powerful; you just need to know how to stack them.