Well, if you're reading this is that you're interested in using WSL to develop PHP-based applications like WordPress on your Windows 10 computer, so I'm not going to dwell any longer and I'm going to get into the nitty-gritty:
Step 1: Enable WSL
As with all Windows features that are not common, before using WSL you have to enable it. To do this, simply open a Power Shell as administrator and run the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 2: Check the requirements for running WSL 2
Launch the Run command with the keystroke combination
R to find out the version number of your Windows:
IMPORTANT: For everything to work correctly, you must have Windows 10 version 2004 or higher installed. In my case, I use version 20H2, which is higher. Use the Windows Upgrade Assistant to upgrade Windows 10.
Step 3: Enable Virtual Machine
Well, we need to activate the Virtual Machine Platform for all this to work. Simply, in the PowerShell, run:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
As it couldn't be missing when it comes to installing things, it's time to restart your computer, so you're already late.
Step 4: Download the Linux kernel
- For computers with x64 architecture, you can download it from this link: Linux kernel in WSL 2 for x64 machines
- For ARM64 machines, download the kernel from this link: Linux kernel in WSL 2 for ARM64 machines
When it's downloaded just run the MSI and as with everything, next, next, next, next....
Step 5: Set WSL 2 as default version
look like is a nonsense, you have to tell Windows that we want to use version 2 of WSL as default. To do this, in a PowerShell window, enter the following command:
wsl --set-default-version 2
Step 6: Install a Linux distribution
This time we are going to use the latest Ubuntu distribution available, version 20.00 LTS, which we will install from the Microsoft Store:
If you want to install another Linux distribution, in this link you have all the available alternatives.
Once you have downloaded the chosen distribution, click Start and the file decompression process will start, which will only have to be executed this first time. During the process you will also be asked to create a username and password. When everything is finished, you will have the distribution ready to be used:
And with this your distribution would be installed.
Remember that all information related to WSL, as well as FAQs and troubleshooting can be found at the Windows Subsystem Documentation for Linux.
In the next chapter we will see how to install a LAMP development environment in WSL.