How to run a local Linux web server in a Windows 11 window
Are you building a website or programming web tools using PHP, MySQL, or other common languages? Having a test site that you can run on your local PC is a huge help. 🌐 However, most web hosting services, including the best ones, use Linux and not Windows as their hosting environment. 🤔 But what if you have a PC running Windows and you want to build a site that will be hosted on a Linux server? We have good news! 🎉
With the service With the built-in Windows Subsystem for Linux (WSL) in Windows 11 or 10, you can create a local Linux web server for testing and developing sites. You simply run Linux in a window and can visit the website in your Windows-based browser, as well as edit key HTML, PHP, or other files with a Windows editor (e.g.: Notepad++, my favorite). You can also browse your server's file system Linux using Windows Explorer. 🖥️
Next, we will show you how to create a local Linux web server running on WSL. We will use AlmaLinux 9 instead of Ubuntu because AlmaLinux is one of the most widely used server operating systems by web hosting providers and is similar to CentOS, which is also widely used. Our dashboard control For the server it will be Virtualmin, as it is a free and easy to use panel. Many people prefer cPanel, but the cPanel license has a cost. 💸
1. Install WSL Windows for Linux) if you don't have it installed yet. 🌟 To do so, enter the command wsl --install
at the command prompt PowerShell. 🚀

(Image credit: Tom's Hardware)
2.🌟 Install AlmaLinux OS 9 for WSL. It is now available in the Microsoft Store for easy download. 🚀

(Image credit: Tom's Hardware)
During this process, you will need to create a username and password for your AlmaLinux instance. 🔐
3. Update your Linux environment with the latest packages. This is crucial to ensure the best performance and security. 🚀
sudo dnf update
4. Set a password for the root user. This is an essential step to protect your system. 🔒
sudo passwd root
5. Install VirtualMin by running the following commands. ⚙️ The downloaded file is a script that will run a series of commands. It is not recommended to install software This way if you don't trust the source. You can read the contents of the script by typing less install.sh
after it has been downloaded.
wget -O install.sh https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh chmod a+x install.sh sudo ./install.sh
Visit the URL provided by your browser (either your machine name or IP address with :10000 at the end). 🌐

6. Log in as root with the password you created. 🔐✨

(Image credit: Future)
7. Navigate through the Post-Installation Wizard, leaving the default values except as noted below. 🚀

(Image credit: Future)
I recommend changing your MariaDB password to one that is easier to remember than the default one. 🔒💡

(Image credit: Future)
To improve your primary nameserver settings, I recommend enabling the “Skip resolvability check” option. This can help optimize the performance of your website and ensure everything runs smoothly 🌐.

(Image credit: Future)
8. Click on **Add new virtual server**. 🌐

(Image credit: Future)
9. Give your site a domain name, admin password, and admin user. 🚀 You may or may not need the username and password, as you may prefer to stay logged in as root. 🔒

(Image credit: Future)
10. Install Phpmyadmin and/or WordPress by navigating to Virtualmin -> Manage Web Applications. Select the applications you want to install and click “Show Installation Options. Then choose the installation options or accept the default options. 🚀

(Image credit: Future)
You can now manage your databases by accessing http://IPaddresss/phpmyadmin in your browser (for example: http://172.18.231.63/phpmyadmin in my case). 🌐
11. Assign a hostname to your IP in C:\Windows\System32\drivers\etc\hosts
. To do this, add the IP address, press tab, and then enter the Spanish name you want to use to access your site. ⚙️ This isn't necessary, as you can always go directly to the IP address in your browser, but it does make browsing your local site a little easier. 🚀

(Image credit: Future)
12. Give all users read and write access to your directory public_html
so that they can access all the folders of the websites through Windows Explorer. 🌐 If you set up a virtual server with a user who owns it — in my case, I called that user “thuser” — the folder containing the website files is /home/[USERNAME]/public_html
(eg: /home/thuser/public_html
). That's where you'll find the file index.html
which is the default home page for your site.
If for some reason you configured the virtual server to run under the root user, the site files will be located in /var/www
. But, if you followed the instructions above, they will be in /home/[USERNAME]/public_html
. 📁
There is just one problem. If you try to navigate to /home/thuser/public_html
In Windows Explorer, you will receive an error message like the following. 🚫

To solve this problem, you have to enter sudo chmod -R 777 [PATH]
in the AlmaLinux command prompt. For example. 🐧✨
sudo chmod -R 777 /home/thuser
This will make the entire home folder available in Windows Explorer. Windows. So, you can use your software favorite code editing software on Windows, such as Notepad++, to open and edit files there. 🖥️✏️

(Image credit: Future)
You can now work on your site and test it on your local PC 🖥️. You can navigate to it in your browser either by going to the IP address or the domain name you chose (e.g. mysite). You can edit the files using Windows editing software and access the database by going to http://mysite/phpmyadmin. Use the following directions to get where you need to go 📍.
Address (assuming mysite as name) | Use |
---|---|
http://mysite | Home page |
http://mysite:10000 | Virtualmin Control Panel |
http://mysite/phpmyadmin | Database Management |
\\wsl.localhost\AlmaLinux-9\home\thuser\public_html | Home page folder in Windows Explorer |
🛠️ For this test site to work properly, it is essential that you have a window open AlmaLinux-9 in your system WindowsWithout this, the web server will not be able to operate properly. 🌐