Published on

Installing Windows Subsystem For Linux For Web Development On Windows


I have been using Windows for PHP and JavaScript development for a few years now. At first, I used gitbash as my shell and since I was running most things in Docker, it worked well. Once Docker fully supported WSL2, I switched to doing development in Linux, on Windows. Docker on Windows is already way faster than a Mac.

Install Windows Linux Subsystem for Local WordPress Development on Windows

In some cases, this is as simple as running wsl --install in PowerShell. Make sure to start PowerShell with administrator privileges. I had to do most of the manual installation steps:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Then I downloaded and installed this msi. Then I set version two of WSL, again from PowerShell with administrator privileges:

wsl --set-default-version 2

I figured this out by reading these links:

Configure For PHP and JavaScript Development

That's how I get started. From there, I create two Linuxes, I wrote posts about both of them:

Setup Git and SSH

Before this setup can be complete, you need to be able to use SSH. Otherwise, you can't do git push to Github.

You could create a new key for this Linux. I prefer to copy keys from the host machine.

First setup your git profile, with something like:

git config --global "Josh Pollock"
git config --global "[email protected]"
git config --global core.autocrlf false
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"

That line tells git to use Windows' credential manger. Then you can copy the keys from Windows to Ubuntu. Make sure to change "roy" to your Windows username:

mkdir ~/.ssh
chmod 600 ~/.ssh/id_rsa
cd ~/.ssh
cp /mnt/c/Users/roy/.ssh/id_rsa* .

I figured this out by reading these links:

Want to talk about this post? Discuss this on Twitter →

Found a typo or want to suggest an edit? Open a pull request →