Skip to main content
  1. Categories/
  2. Articles/

How to Install WSL on Windows and Set Up Ubuntu for Web Development

1128 words·6 mins·
Author
Mahmoud Adel
Fullstack Web Developer
Table of Contents

If you’re a web developer working on Windows, you’ve probably run into the classic problem: your local environment doesn’t match your production server—which is almost always running Linux.

The practical and straightforward solution? Use WSL (Windows Subsystem for Linux) and install Ubuntu as your development environment.

In this guide, you’ll learn how to:

  • Install WSL from scratch
  • Install Ubuntu
  • Install Git
  • Install Docker and Docker Compose
  • Set up a real-world Linux-based development environment

Why Use WSL as a Web Developer?
#

Before jumping in, let’s simplify the idea.

Instead of:

  • Installing Linux on a separate machine
  • Or running a full virtual machine like VirtualBox

WSL allows you to run Linux directly inside Windows—without the heavy resource usage of a traditional VM.

Here’s a quick comparison:

WSLVirtual Machine
Fast and lightweightConsumes more RAM and CPU
Direct integration with WindowsFully isolated system
Ideal for web developmentBetter for full OS testing

If you’re a web developer who wants the convenience of Windows (apps, games, daily tools) while developing in a professional Linux environment, WSL is the smart choice.

Minimum Requirements
#

The good news? Almost any modern machine can handle it:

  • Windows 10 (version 2004 or later)
  • Windows 11
  • At least 8GB RAM (more is better)

Step 1: Install WSL
#

Open PowerShell as Administrator and run:

wsl --install

What does this command do?

  • Enables WSL
  • Enables the Virtual Machine Platform
  • Installs WSL 2
  • Automatically installs Ubuntu

Once installation finishes, restart your computer.

Step 2: Set Up Ubuntu for the First Time
#

After restarting:

  1. Open Ubuntu from the Start menu.
  2. Wait for the initial setup to complete.
  3. Create:
    • A username
    • A password

That’s it—you now have a full Linux environment running inside Windows.

Verify You’re Using WSL 2
#

In PowerShell, run:

wsl -l -v

If the version shows 2, you’re good to go.

If it shows version 1, run:

wsl --set-default-version 2

Step 3: Update Ubuntu
#

Inside Ubuntu, run:

sudo apt update
sudo apt upgrade -y

If you’ve worked with Ubuntu on a VPS or as a standalone OS before, the environment will feel instantly familiar.

Step 4: Install Git
#

Every web developer needs Git to manage and update repositories.

Install it with:

sudo apt install git -y

Verify installation:

git --version

Then configure your identity:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Step 5: Install Docker (The Professional Way)
#

Docker is essential for running:

  • Node.js
  • PHP
  • Laravel
  • MySQL
  • PostgreSQL
  • Redis
  • And virtually any modern stack

Yes, you could install Docker directly on Windows via Docker Desktop. But that GUI-based approach consumes more system resources.

Instead, we’ll install Docker directly inside Ubuntu—just like you would on a real production server.

1. Install Required Packages
#

sudo apt install ca-certificates curl gnupg -y

2. Add Docker’s Official GPG Key
#

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

3. Add the Docker Repository
#

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4. Install Docker
#

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

Step 6: Run Docker Without sudo
#

Add your user to the Docker group:

sudo usermod -aG docker $USER

Then exit:

exit

Reopen Ubuntu and test:

docker --version

Step 7: Using Docker Compose
#

Docker Compose is now built directly into Docker as:

docker compose

Check it with:

docker compose version

Notice the difference:

docker-composedocker compose

Quick Docker Test
#

Create a file:

nano docker-compose.yml

Paste:

services:
  app:
    image: nginx
    ports:
      - "8080:80"

Run:

docker compose up

Open your browser at:

http://localhost:8080

You should see the Nginx welcome page.

The Best Way to Work as a Web Developer Using WSL
#

If you’re using Windows + WSL (Ubuntu), organizing your development environment properly will save you a lot of time and help you avoid performance issues.

1. Store Your Projects Inside Linux, Not in C Drive
#

One of the most common mistakes is storing your projects inside a Windows path like:

C:\Users\...

It’s much better to keep all your projects inside the Linux environment itself. This ensures better performance and avoids permission-related issues.

Navigate to your user directory inside Ubuntu:

cd /home/mahmoud

Then create a folder to hold all your projects:

mkdir apps

Your path will now look like this:

/home/mahmoud/apps

From now on, create every new project inside this folder.

2. Use VS Code with the WSL Extension
#

The best development experience with WSL is achieved by using:

Visual Studio Code

With the following extension installed:

WSL Extension

After installing the extension, you can open any project inside Linux directly from VS Code without dealing with path or permission issues.

3. Automatically Launch Ubuntu Using Cmder
#

Instead of manually opening WSL every time, you can simplify the process using:

Cmder

Steps:
#

1.Download Cmder. 2. Go to Settings → Startup → Tasks. 3. Create a new task named: Ubuntu 4. Add the following command inside it:

wsl -d Ubuntu
  1. From General → Choose your startup task, select the task you just created.

Now, whenever you open Cmder, it will automatically launch Ubuntu.

4. Automatically Navigate to Your Projects Folder
#

Instead of typing this command every time:

cd /home/mahmoud/apps

You can configure it once inside your shell configuration file.

Open the file:

nano ~/.bashrc

Add the following lines at the end of the file:

PS1='\u@\h [\W] ➜ '
cd /home/mahmoud/apps

Then apply the changes:

source ~/.bashrc

Now, when you reopen Cmder, you’ll automatically start inside your projects folder like this:

mahmoud@SherifAdel [apps]

Your development environment is now clean, fast, and free from repetitive setup steps.

Do You Need Docker Desktop?
#

You can work entirely without Docker Desktop if Docker is installed inside Ubuntu as shown above.

Docker Desktop provides:

  • A graphical interface
  • Container management tools
  • Easier setup for beginners

But for professional developers? Installing Docker inside Ubuntu is cleaner, lighter, and closer to a real production server experience.

What You’re Now Ready to Build
#

You can confidently develop:

  • Laravel
  • Node.js
  • Vue
  • React
  • Angular
  • WordPress
  • Or any modern stack you want to learn

All inside a real Linux environment—while still using Windows as your main OS.

Final Thoughts
#

With:

  • WSL 2
  • Ubuntu
  • Git
  • Docker + Compose

You now have a professional-grade development environment that mirrors production servers by roughly 95%.

This dramatically reduces issues like:

  • “It works on my machine, but not on the server.”
  • Version mismatches
  • Permission and path-related errors

If this setup feels overwhelming and you prefer something simpler, you might consider using Laragon as an easier alternative for beginners.

But if you’re aiming for a truly professional workflow, WSL is the smarter long-term investment.

Related