Want to run a web server on your Windows 10 computer, but don't want to bother with manual configuration or installing bulky packages like Denwer? There's a great, modern way to do it. You can use the Windows Subsystem for Linux (WSL) to deploy a full-fledged web development environment right on your machine.
WSL allows you to run a Linux environment without leaving Windows. This is ideal for installing Apache, MySQL, and PHP. You get all the benefits and flexibility of a real server, but you work in your familiar operating system. We'll look at how to do this in both versions of the subsystem — WSL 1 and WSL 2.
This approach is great for local website development, script testing, or learning web technologies. Everything will run in isolation on your computer without interfering with the main system, and you won't need to create a virtual machine or reinstall the OS.
- Enabling the Windows subsystem for Linux.
- Create a directory for the web project.
- Installing the necessary programs in Ubuntu for Windows 10.
- Installing Apache.
- Installing the MySQL server.
- Let's enable the Mod rewrite module in Apache:
- Changing the MySQL authentication method for the root user.
- Creating a database.
- Installing phpMyAdmin.
- Configuring virtual hosts in Apache.
- Redirect test.local to the local web server.
- Commands to start and stop the web server.
- Check the web server's functionality.
Enabling the Windows subsystem for Linux.
To enable the component“Windows Subsystem for Linux”in Windows 10, you need to do the following:
Step 1: Using the command: optionalfeatures in the dialog box “Run” open “Windows Components.”
Step 2: Enable the option“Windows Subsystem for Linux”.
Step 3: Go to Microsoft Store download and install the application. Ubuntu for Windows.

Step 4:Using the menu “Start” runUbuntu.In the terminal window, you will need to enter a new UNIX user name when you first start the game.(username)and password(password).

For more details on how to do this, see the guides:
- How to install the WSL 2 Windows subsystem for Linux in Windows 10
- How to install the Wsl 1 Windows subsystem for Linux.
- Official instructions from Microsoft.
Create a directory for the web project.
When using WSL 1, it is recommended to place project files on Windows file system disks – C, D, E. If you are using WSL 2, you can also use local drives or create a directory for the site in the Linux file system.
Step 5:Create a directory for the site (project) in Windows 10 File Explorer. test.local:
C:\Projects\test.local\public_html

If you are using WSL 2, it is recommended to create a directory for the site in the Linux file system. In this case, we will place the project folder here: \home\main\projects\test.local\public_html
To do this, run the command:
sudo mkdir -p /home/main/projects/test.local/public_html
Where replace "main" to the name of the UNIX user created when wsl was first launched.
To avoid access problems, execute the command:
Here, also replace "main" to your UNIX username.

This will eliminate errors and ensure maximum performance.
Step 6: Kaccess WSL Linux files from Windows 10 File Explorer.
While in the Linux FS directory, enter:
A file explorer window will open within your Linux distribution.
For more details, see our article:Access WSL Linux files using Windows 10 File Explorer.

Also, to make it easier to work with directories in the Linux file system, you can install Ubuntu, for example. “Midnight Commander”:
Midnight Commander is launched by entering the command:
Installing the necessary programs in Ubuntu for Windows 10.
Step 7:Using the menu “Start” runUbuntu.
Step 8:Update the local apt package index in Ubuntu by running the command:

Step 9:After that, you need to update the installed software:
On request “Do you want to continue? [Y/n]” press the key Y.

Installing Apache.
The Apache web server is used by more than half of all active websites. It is a very powerful and flexible tool.
Step 10:Install Apache by running the command:
You will see a list of packages that will be installed, as well as the amount of disk space they will occupy. PressYto continue the installation.

Installing the MySQL server.
MySQL is a database management system. It organizes and provides access to databases where the site can store information.
Step 11:Install the MySQL server:
sudo apt install mysql-server
PressYto continue the installation. After the installation is complete, we will need to run some additional commands to configure our MySQL environment

Step 12:Let's install PHP and other packages needed for web development:
PHP is the component responsible for processing code to display dynamic content.
sudo apt install php libapache2-mod-php php-mysql php-xml php-curl
Note: If you need to install a specific version of php, for example 7.4.x, you need to run the command:
Let's enable the Mod rewrite module in Apache:
In short, mod_rewrite — this is a module for the Apache web server that performs URL conversion.
Step 13:Run the command:
If you develop websites or are learning to program in PHP with databases, it is convenient to have your own web server right on your computer. In Windows 10, this can be done using WSL, a subsystem that runs Linux inside the system. By installing WSL 1 or WSL 2, you can easily configure Apache, MySQL, and PHP, just like on a real server. The difference between WSL 1 and WSL 2 is in speed and compatibility: the second version works faster, especially with files, but the first is easier to set up. The main thing is that the choice depends on your tasks, but both options allow you to quickly set up a local site and start working.
Changing the MySQL authentication method for the root user.
You need to change the MySQL authentication method for the root user by performing the following steps:
Step 14:Let's start the mysql service.
Step 15:Connect to the MySQL server under the standard root user that was created when MySQL was installed on your computer:
Step 16:When prompted for a password, press Enter, since the default root user created during installation does not have a password.

Note: On Ubuntu servers using MySQL (5.7 and later), root user authentication is performed using the plugin.auth_socket, rather than using a password. In many cases, this increases security, but it can complicate the configuration of root user access for phpMyAdmin and other programs.
Step 17:To check the authentication method used for the root user, run the command:
SELECT user, authentication_string, plugin, host FROM mysql.user WHERE user="root";

Step 18:If you see that authentication using the auth_socket plugin is used in the response to the request, you need to change this setting. To do this, enter the command:
ALTER USER ‘root’@'localhost' IDENTIFIED WITH mysql_native_password BY ‘root’;
Step 19:Execute the FLUSH PRIVILEGES command, which will apply the changes:
Creating a database.
Step 20:Let's create a database for the web project test.local. To do this, enter the following command in the MySQL command line:
CREATE DATABASE testlocal;
Step 21:To finish working with the MySQL command line, exit it:
Installing phpMyAdmin.
Step 22:Execute the command:
sudo apt install phpmyadmin

Step 23:In the first dialog box, press the space bar to select Apache, then press the Tab key, and then Enter.

Step 24:Select Yes, to configure the database on request, use dbconfig-common.

Step 25:Specify the password for the MySQL root user.

Step 26:Confirm the password
Step 27:Enable the necessary PHP extensions:
Step 28:Restart Apache:
sudo service apache2 restart
You can now access phpMyAdmin at the following URL: http://localhost/phpmyadmin/ You can log in using your username root and password root, configured during MySQL installation.

Configuring virtual hosts in Apache.
In Ubuntu, the Apache virtual host settings file is located at the following path /etc/apache2/sites-available/*.conf. Apache already has one default virtual host configured in the file 000-default.conf. Let's use this file as a basis.
Step 29:Create a copy of the file 000-default.conf execute the command:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/test.local.conf
Step 30:Let's make changes to the test.local.conf file using the nano editor:

The contents of the test.com.conf file after editing for Wsl 2 if you have created a directory for the site in the Linux file system:
Attention: Don't forget to replace the UNIX username with your own (Step: 7), in my case it is almanex.

The contents of the test.com.conf file after edits for Wsl 1 and Wsl 2, where the project files are located on the Windows file system disk – C, D, E:
Attention: Don't forget to replace the drive letter! In the example, we use the drive C.

Step 31:After making changes, save and close the file with the key combination CTRLX. Confirm the operation with the Y key and press ENTER.
Step 32:Let's enable a new virtual host using the utility a2ensite:
sudo a2ensite test.local.conf
Step 33:Next, disable the default site 000-default.conf:
sudo a2dissite 000-default.conf
Step 34:Restart the Apache service:
sudo service apache2 restart
Redirect test.local to the local web server.
Your project is available at http://localhost/
In order for the domain name http://test.local was connected to your local web server, open the hosts file located at C:\Windows\System32\drivers\etc and add the following lines to it:
127.0.0.1 test.local
172.30.69.65 test.local
To determine the IP address of your network interface (in my case, it is 172.30.69.65), you can use the commandipaddress in the terminal (see the image below).

Commands to start and stop the web server.
That's it, now before you start working on your web project, you need to start Apache and MySQL. To do this, enter the following commands in sequence:
sudo service apache2 start
To stop the web server:
sudo service apache2 stop
Optional: To make it easier to start and stop the web server, you can create bash scripts start.sh and stop.sh.

How to create the start.sh script:
Step 1:Open the terminal and create a file with the command:
Step 2:Paste the following content, replacing password with the password you set for the Ubuntu user:
#!/bin/bash
echo password | sudo -S sudo service apache2 start
echo password | sudo -S sudo service mysql start
exit 0

Step 3:You need to edit the access rights for start.sh. Execute the command:
sudo chmod -R 755 ./start.sh
The stop.sh script:
Step 4:Create a file with the command:
Contents of the stop.sh file:
#!/bin/bash
echo password | sudo -S sudo service apache2 stop
echo password | sudo -S sudo service mysql stop
exit 0
Step 5:Edit access rights:
sudo chmod -R 755 ./stop.sh
Check the web server's functionality.
To check the web server's performance, let's install test.local content management system, such as OctoberCMS, MODX Revolution, or WordPress.
To do this, download the WordPress system archive from the official website and unzip it into the directory we created.
C:\Projects\test.local\public_html
or
/home/main/projects/test.local/public_html
To install the system, open the wizard. Open the address http://test.local in your browser. Then answer all the wizard's questions and click the button. “Next”, enter database connection details testlocal etc.

Wait for the installation process to complete. Done!
As you can see, installing a local server in WSL is not as difficult as it may seem at first glance. The main thing is to follow the instructions step by step and not be afraid of the command line. This method gives you full access to a powerful and flexible web development tool right on your Windows computer.
The choice between WSL 1 and WSL 2 depends on your tasks. If you work with files in the Windows folder, WSL 1 may be faster. For everything else, especially for working with databases and applications that require high performance, WSL 2 will be the best solution due to its modern architecture.
Now you have your own test environment, almost identical to real hosting. You can safely create and debug websites, install CMS such as WordPress, and experiment without fear of breaking anything on the internet. This is your personal playground for creativity and learning.
The rest is up to you. Explore the server settings, try different versions of PHP, connect other databases. This local server is your reliable foundation for any web projects. Good luck with your development!









