Setting up WSL2 + Ubuntu for PHP & Laravel Development

- - Laravel

Setting up Ubuntu/Linux in Windows for Development

Developing on Windows used to mean dealing with constant environment discrepancies. Fortunately, the Windows Subsystem for Linux (WSL2) paired with Ubuntu completely changes the game. Furthermore, it gives you a native Linux environment without ever leaving Windows. Here is how you can get it configured step-by-step.

First, open PowerShell as Administrator and run the installation command to kick off the process:

wsl --install -d Ubuntu

This command sets up the Virtual Machine Platform, installs WSL, and downloads Ubuntu seamlessly. Additionally, you will need to reboot your system once it finishes.

Resolving Common Installation Errors (0x80370114)

Sometimes, launching Ubuntu from the Start menu triggers an unexpected startup error:

Searching for Ubuntu in the Windows Start Menu
Launching Ubuntu from the Windows Start menu.
WslRegisterDistribution failed with error 0x80370114: required feature not installed.

Typically, this error means the Virtual Machine Platform or hardware virtualization is disabled. To check your current feature status, execute these commands in PowerShell as Administrator:

dism.exe /online /get-featureinfo /featurename:VirtualMachinePlatform
dism.exe /online /get-featureinfo /featurename:Microsoft-Windows-Subsystem-Linux

If either feature shows as disabled, enable them immediately by running:

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

After executing those commands, make sure you reboot your computer.

Welcome to Windows Subsystem for Linux dashboard overview
The WSL control panel and overview interface.

Creating Your Unix User Account

Once your system reboots and Ubuntu launches successfully, the terminal will prompt you to create your default Unix user account:

Setting up the default Unix user account and password
Setting up your Unix user account, password preferences, and telemetry options.

Simply enter your desired username, create a secure password, and select your telemetry preferences.

You are now completely ready to install PHP, Composer, and Laravel inside your brand new WSL2 environment!

Post Tags:
Join the Newsletter

Sign up for our personalized daily newsletter

Kodesmart

#1 GUIDE TO DRUPAL, WORDPRESS, CSS AND CUSTOM CODING | BEGINNER TO PRO

Leave a Reply

Your email address will not be published. Required fields are marked *