How to run linux environment with LAMP on Windows WSL

By | 6. April 2023
  1. Install Linux on Windows with WSL

You can now install everything you need to run WSL with a single command. Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting “Run as administrator”, enter the wsl –install command, then restart your machine.

wsl –install

Restart and continue with setup

 Before installing the first LAMP component, ensure the package list on the system is up to date. In the terminal, type:

sudo apt update

Now, to install the Lamp server, we can use the below given single command on WSL Linux instead of issuing one by one for each service to get configured on the system.

sudo apt install lamp-server^

add these 2 lines in /etc/apache2/apache2.conf :

Servername localhost
AcceptFilter http none

sudo nano /etc/apache2/apache2.conf

Start service

sudo service apache2 start

Check if Apache installed correctly by checking the Apache service status:

sudo service apache2 status

Next, make sure that the UFW firewall contains the Apache profiles by typing in the following command:

sudo ufw app list

Ensure the Apache Full profile allows the traffic on ports 80 and 443 by running the command:

sudo ufw app info “Apache Full”

Run command to see ip in use

ip address

Now you can verify on you windows pc that Appache is running


Test PHP Processing on Web Server. Create a file in the web root directory by typing the following command:

sudo nano /var/www/html/info.php

Add conntent

<?php phpinfo (); ?>

Save file.


Verify from your Windows PC host

If you would like to add Midnight Commander then  you need to enable the universe repository:

sudo add-apt-repository universe

and then install mc:

sudo apt install mc

Leave a Reply