Jump to content
  • Sign Up
×
×
  • Create New...

Recommended Posts

  • Diamond Member

This is the hidden content, please

How to run a local Linux web server running in a Windows 11 window

If you’re building a website or programming web tools using PHP, MySQL or other common languages, it helps to have a test site you can run on your local PC. However, most web hosting services, including the best web hosting services, use Linux, not Windows as their hosting environments. But what if you have a Windows PC and want to build a site that’s going to live on a Linux server?

We have good news. Using Windows 11 or 10’s built-in Windows Subsystem for Linux (WSL) service, you can create a local Linux web server that you can use locally for testing and building a site. You simply run Linux in a window and then you can visit the website in your Windows-based web browser and edit the key HTML, PHP or other files in a Windows-based editor (ex:

This is the hidden content, please
, my fave). You can even navigate your Linux server’s file system using Windows Explorer.

Below, we’ll show you how to create a local Linux web server running in WSL. We’ll use AlmaLinux 9 rather than Ubuntu because AlmaLinux is one of the most commonly used server operating systems for web hosts and it’s similar to CentOS which is also used by many hosts. Our server control panel will be Virtualmin, because it’s a free, easy-to-use control panel. Many people prefer cPanel, but a license for cPanel costs money.

1. Install WSL (Windows Subsystem for Linux) if you don’t have it installed already. You do this by entering wsl –install at a PowerShell command prompt.

(Image credit: Tom’s Hardware)

2. Install

This is the hidden content, please
for WSL. It’s available in the
This is the hidden content, please
Store.

(Image credit: Tom’s Hardware)

During this process, you will need to create a username and password for your AlmaLinux instance.

3. Update the Linux environment with the latest packages.

Get Tom’s Hardware’s best news and in-depth reviews, straight to your inbox.

sudo dnf update

4. Set a password for the root user.

sudo passwd root

5. Install VirtualMin by issuing the following commands. The downloaded file is a shell script that will run a series of commands. It is not best practice to install software via this method if the source is not trusted. You can read the contents of the script by typing less install.sh after it has been downloaded.

wget -O install.sh 

chmod a+x install.sh
sudo ./install.sh

5. Navigate to the URL it gives you in your browser (either your machine name or IP address with :10000 at the end)

(Image credit: Tom’s Hardware)

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

(Image credit: Future)

7. Navigate through the Post-Installation Wizard, leaving defaults except as noted below.

(Image credit: Future)

I recommend changing the MariaDB password to something easier to remember than the default.

(Image credit: Future)

Toggle “Skip check for resolvability” to on for the Primary nameserver

(Image credit: Future)

8. Click 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 remain logged in as root.

(Image credit: Future)

10. Install Phpmyadmin and / or Wordpress by navigating to Virtualmin -> Manage Web Apps, selecting them and clicking Show Install Options then choosing install options or accepting the defaults.

(Image credit: Future)

You should now be able to manage your databases by going to in your browser (ex: in my case).

11. Assign a host name to your IP in C:\Windows\System32\drivers\etc\hosts. You do this by adding the IP address, hitting tab and then entering the plain-English name you want to use to access your site. This isn’t necessary as you can always just go to the IP address in your browser, but it makes browsing your local site a little easier.

(Image credit: Future)

13. Give all users read and write access to your public_html directory so you can access all of the websites’ folders via Windows Explorer.

If you set up a virtual server with a user that owns it — in my case, I called that user “thuser” — the folder containing the website files is /home/[USERNAME]/public_html (ex: /home/thuser/public_html). That’s where you’ll find the index.html file that has the default home page for your site.

If, for some reason, you set up the virtual server to run under the root user, the files for the site will be located in /var/www. But, if you followed the instructions above, they are in /home/[USERNAME]/public_html.

There’s just one problem. If you try to navigate to /home/thuser/public_html in Windows Explorer, you get an error message like the one below.

(Image credit: Future)

To fix this problem, you must enter sudo chmod -R 777 [PATH] at the AlmaLinux command prompt. For example.

sudo chmod -R 777 /home/thuser

That will make the entire home folder available in Windows Explorer. Then you can use your favorite Windows code editing software — Notepad++ for example, to open and edit files there.

(Image credit: Future)

Now you can 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 domain name you chose (ex: mysite). You can edit the files using Windows editing software and access the database by going to http://mysite/phpmyadmin.

Use the following addresses to get to where you need to.

Swipe to scroll horizontally
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

In order for this test site to work, you need to make sure that there’s an AlmaLinux-9 window open in Windows. Otherwise, the web server won’t work.



This is the hidden content, please

#run #local #Linux #web #server #running #Windows #window

This is the hidden content, please

This is the hidden content, please

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Vote for the server

    To vote for this server you must login.

    Jim Carrey Flirting GIF

  • Recently Browsing   0 members

    • No registered users viewing this page.

Important Information

Privacy Notice: We utilize cookies to optimize your browsing experience and analyze website traffic. By consenting, you acknowledge and agree to our Cookie Policy, ensuring your privacy preferences are respected.