Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ashwinmram's avatar

Setting up a Laravel Dev machine on Windows 10 with WSL (Windows Subsystem for Linux) enabled

The first step of course would be to activate ASL. I did this by running the following command through Windows PowerShell as an Administrator:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

The next step was to install the Linux distro through the Microsoft Store and I went with Ubutu 18.04 LTS as I was already familiar with it and never had any problems.

I then proceeded to install PHP 7.3, composer, mysql, redis, supervisor, node, npm and oh my zsh. There are a multitude of resources of how to do this online, so Im sorry but Im going to save myself the effort to add all the commands and provide you with the links instead.

The important thing though is I didnt install Apache but having used Laravel Valet on my Mac as well as on Ubuntu (valet-linux) and found the entire workflow of adding projects and accessing them from the browser a no brainer.

The one thing I have to point out is valet-linux does not work with WSL. Please use valet-wsl instead but dont forget to install the prerequisite Ubuntu packages.

"Valet for WSL provides a way to quickly setup a development environment for Laravel using Valet in Windows Subsystem for Linux." - valeryan

By the way, I noticed I could not even do apt-get update after installation of valet-linux initially and had to add back the nameservers to fix this. Am not sure if this is even required if you install valet-wsl right away.

The last hurdle for me was automating the startup of the web stack upon launching the Ubuntu App after restarting Windows. Here is what I added to my ~/.zshrc file:

sudo valet start
sudo service supervisor start
sudo service redis-server start
sudo service mysql start
sudo supervisorctl start all

I used supervisor to launch Laravel Echo Server and Laravel Horizon upon boot. Please note that systemctl in not available in WSL based on what I read.

You will also need to add an entry into the Windows hosts file in order to access your web app on 127.0.0.1. Last but not least, in order to access your code in a text editor through Windows, you will need to store your code on the Windows file system by creating a sym link from WSL to Windows.

ln -s /mnt/c/Users/username/Documents/Code/projectname

I hope this post helps someone to set up their development environment on Windows! Please read the entire blog I wrote on this which has more external links as well as some information about the laptop I am using.

https://ashwinmram.com/2019/09/08/setting-up-a-laravel-dev-machine-on-windows-10-with-wsl-windows-subsystem-for-linux-enabled/

0 likes
9 replies
hollyit's avatar

How are you finding performance under WSL? Last couple times I tried it, the IO performance issues just hurt. I was noticing build times on some Vue stuff taking 4-5 times longer than just doing it straight on Windows. Even just doing straight Laravel stuff I saw a big slowdown from my regular Windows (using Neard) flow. One app that would take 80-100ms to respond on Windows took over 500ms to respond on WSL.

I would really love to be able to switch totally to WSL, but right now am holding out for WSL2. The early reports on it are really promising.

ashwinmram's avatar

Hi @jlrdw My pleasure :)

Hi @hollyit

No issues for me regarding performance. It is slower than my Digital Ocean droplet, but not significant enough to be painful.

My web app runs without any lag whatsoever.

I'm looking forward to WSL2 as well, but for now I'm very happy with my workflow.

gymdone's avatar

I'm using WSL2 with Ubuntu 20 on Win v2004 and it's working great. I started out using my dev area under /mnt/c/Users/username/ but everyting is 10x faster without the windows file system. I moved to /home/username/ Using Laravel 7 and vscode.

1 like
ashwinmram's avatar

That's awesome that you are on v2004 with WSL2 @gymdone ! I still have to wait to upgrade as it is not giving me the option a the moment unfortunately.

May I please check how you are able to access the code in /home/username through VS Code? Is VS Code running in Linux or on the Windows side of things?

Or is Ubuntu 20 a GUI version of Ubuntu? Let me do a little more digging but thanks for the suggestion as it would definitely help if things run 10X faster!

gymdone's avatar

Yes, VS Code !! When I open a Bash shell in Ubuntu 20 WSL2 and enter

$ code .

The WSL folks include in the Linux path: /mnt/c/Program Files/Microsoft VS Code/bin

So vscode runs and on the first run it automatically enables it's Remote-WSL mode! VS Code stays actually running under windows but seamlessly remotes into WSL where the files are stored and run. I'm using Windows Terminal Preview 1.2.2 and using Bash into WSL and I configured the terminal inside of vscode to run the same!

All works just great!

1 like
ashwinmram's avatar

The challenge I was having was that Sublime text is not as seamlessly integrated as VS Code out of the box. I did find a solution though thanks to your reply :) Thanks again!

upnorthal's avatar

I'm now using WSL2 myself. Running any kind of "watch" on the native Ubuntu system is lightening fast.

As above, MS Code appears to integrate with it directly resulting in no speed lost.

PHP Storm on the other hand, has to access the file from Windows via the \wsl$ share which is slow at the best of times. I believe Microsoft are aware of the file share access issues from Windows and hopefully we will see improvements soon.

Loving the new Windows Terminal app 2. Its not quite as polished as the Mac's Iterm2, but you can get it looking pretty close font wise and colours. Shame you can't assign a single hotkey to launch terminal - yet.

1 like

Please or to participate in this conversation.