Transform a clean WSL 2 Ubuntu install into a full-featured, secure web‑development environment in just minutes. Whether you’re building PHP, Node, or static sites, these scripts handle installation, configuration, and SSL for you—so you can focus on coding.
- 📝 Overview
- 🛠️ Installation
- ⚡️ Quick Start
- 🧰 Usage
- 🔒 Trusting SSL Certificates
- 🛠️ Other Stuff
- 🤝 Contributing
- ⚖️ License
- 🙏 Acknowledgments
This repository provides a set of Bash scripts to automate every step of provisioning a web‑development environment on Windows 10/11 via WSL 2:
- Core services: Nginx with HTTP/2, MySQL (MariaDB fallback), Redis for caching, and Node LTS for JavaScript workloads.
- PHP ecosystem: Parallel PHP 8.2, 8.3, and 8.4 installations, PHP-FPM pools, Composer installer, and an intelligent wrapper to pick the right PHP version per project.
- Developer tooling: Zsh with Oh My Zsh, Powerlevel10k theme, autosuggestions, and syntax highlighting for a blazing-fast shell experience.
- HTTPS everywhere: Locally‑trusted
*.testSSL certificates, automated Nginx virtual host generation, and hosts file updates on Windows. - Resilience: Quiet, resumable installer with progress bars and state checkpoints—won’t leave your system half‑configured.
With these scripts, setting up a fresh WSL 2 instance becomes a single-command task, saving hours of manual work.
- Windows Version: Windows 10 (2004+) or Windows 11 with WSL 2 support.
- Virtualization: Enabled in BIOS/UEFI.
- Admin Rights: Required for enabling features and updating hosts file.
Note: Many steps require elevated privileges. Launch Windows Terminal or PowerShell as Administrator to avoid permission errors.
- Open an elevated PowerShell and enable required features:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Reboot your machine.
- Install the WSL 2 Linux kernel from Microsoft:
- Download from: https://aka.ms/wsl2kernel
- Set your default distro version to WSL 2:
wsl --set-default-version 2
- Install Ubuntu 22.04 LTS (or another supported distro) from the Microsoft Store.
- Launch the distro once (via your Admin Terminal) to finalize installation.
Why? Powerlevel10k uses special glyphs for icons and powerline symbols.
- Download the four MesloLGS NF font files (Regular, Bold, Italic, Bold Italic) from: https://github.com/romkatv/powerlevel10k-media
- Install each font by right-click → Install for all users.
- In Windows Terminal settings, set the font face to MesloLGS NF.
- Verify inside WSL:
ls /mnt/c/Windows/Fonts | grep 'MesloLGS NF'
- Clone the repo and make scripts executable
git clone https://github.com/pedr0cazz/wsl-scripts.git ~/.wsl_scripts chmod +x ~/.wsl_scripts/*.sh
- Run the installer
~/.wsl_scripts/wsl-setup.sh- The script will prompt for your project root (
~/wwwby default), SSL directory (~/ssl), and helper-scripts path. - Progress indicators and automatic rollback on errors ensure a reliable run.
- The script will prompt for your project root (
- Open a new shell or reload Zsh
source ~/.zshrc
- If you dont like the choosen settings you can rerun the p10k command
p10k configure
Result: You now have Nginx, PHP-FPM, MySQL, Redis, Node, and Composer configured, plus a fancy Zsh prompt ready to go.
- Project root: Defined during installation (
$WEB_ROOT, default~/www). - Add a project: Create a directory under your root. Example:
On your next new shell (or manual run of
mkdir -p "$WEB_ROOT/my-app"ssl-manager.sh), a vhostmy-app.testand SSL cert will be generated. - Remove a project: Delete the directory:
The script will detect the missing folder and clean up its Nginx configuration and Windows hosts entry.
rm -rf "$WEB_ROOT/my-app"
Run the SSL manager at any time to sync your project directories with Nginx configs and certificates:
~/.wsl_scripts/ssl-manager.shNo shell restart needed.
- Install and scaffold a new Laravel project using the Laravel installer:
# Install the Laravel installer globally composer global require laravel/installer # Scaffold a new project named "blog" cd "$WEB_ROOT" laravel new blog
- Open a new shell to auto-generate OR manually run the SSL manager:
~/.wsl_scripts/ssl-manager.sh- Nginx vhost
blog.test - Self-signed SSL cert trusted by your Windows host
- Nginx vhost
- Access your site securely:
https://blog.test
- If permissions issues arise, set correct ownership and mode:
sudo chown -R "$USER":"$USER" blog chmod -R 775 blog/storage blog/bootstrap/cache cd ~/blog sudo chown -R $USER:www-data storage bootstrap/cache sudo chmod -R 775 storage bootstrap/cache
By default the installer generates a custom CA and issues all *.test certs.
- Copy the root CA to Windows and rename to
.crt:cp ~/ssl/ca/rootCA.pem /mnt/c/Users/<YourUser>/Desktop/rootCA.crt
- On Windows double-click
rootCA.crt→ Install Certificate. - In the Certificate Import Wizard:
- Choose Local Machine
- Select Place all certificates in the following store → Browse → Trusted Root Certification Authorities
- Click Next → Finish.
- Restart your browser.
Now any *.test site issued by your CA will load without warnings.
Set your name and email for commits:
# Replace with your identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"Already have projects in Laragon? Copy them into WSL:
cp -r /mnt/c/laragon/www/* "$WEB_ROOT/"Then run ssl-manager.sh to auto-generate vhosts and certs.
Reuse existing Windows SSH keys:
mkdir -p ~/.ssh
cp /mnt/c/Users/<YourWindowsUser>/.ssh/id_rsa* ~/.ssh/
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
ssh-add ~/.ssh/id_rsaThis enables passwordless Git over SSH inside WSL.
Replace 8.4 with the desired version:
sudo apt install php8.4 php8.4-fpm php8.4-mysql php8.4-redis php8.4-curl php8.4-zip php8.4-gd php8.4-mbstring php8.4-bcmath php8.4-xml php8.4-soap php8.4-intlContributed by IvoMiranda, the wsl_nginx_gui.py script provides a lightweight graphical interface for Windows to prevent WSL2 from shutting down due to inactivity by periodically checking the Nginx service status.
- Runs a periodic status check of Nginx in WSL2 every few seconds (customizable).
- Keeps WSL2 active as long as the application window remains open.
- Displays a timer showing the time since the last check.
- Ensure Python is installed on your Windows host.
- Run the script from Windows:
python wsl_nginx_gui.py
- Adjust the interval by modifying the CHECK_INTERVAL_MS variable at the top of the script.
Contributions, issues, and feature requests are welcome!
- Fork the repo.
- Create a feature branch (
git checkout -b feature-name). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-name). - Open a Pull Request.
Please follow the Contributor Covenant guidelines.
This project is licensed under the MIT License. See LICENSE for details.
- Powerlevel10k for the Zsh theme
- Ubuntu, Nginx, MySQL, Redis, PHP, Node.js, Composer, Oh My Zsh for the underlying technologies
- Open‑source community contributors and maintainers
Happy coding—and enjoy your new WSL 2 web‑dev environment! 🚀