How to Set up a Web Server on Windows PC

What is a web server? A Web Sever is a simple program that allows the access of files stored on a computer to another computer over the network or internet. Most of the online services and websites run on web servers. So, if you want, you can also set up a web server on your Windows PC and host your website there.

There may be several reasons to create your web server. For example- file-sharing or publishing a website. In simple terms, you choose a directory on your computer and put files like music, video, documents, etc. in that directory. Now, when you put the IP address or hostname of your computer the in web browser, you can see all the files from that folder. You can also download those files.

SEE ALSO: How to Make Your Computer a Time Server?

Set up a Web Server on your Windows PC using Apache Client

To create your web server, you need a few things. First, you need to install Apache server client on your Windows PC. After that, create a directory for your website files. Finally, configure your web server.

If you wish to access your server from the internet, you also need an active internet connection with a fixed public IP address and port forwarding.

Step 1: Create a Document Directory and Default Page for the Web Server

First of all, create a folder in any of the disk drives on your computer and name it as MyServer. You can also give it any other name, we have used this name for simplicity.

Now, note down the path of this folder. In our case folder path is “D:\MyServer“. We will create a index.html file in this folder with some text. Why index.html? Because by default web server displays the index.html file when you type the website address in the browser.

Create Sample Index.html File And Place It In Your Document Root Directory of your web server apache
Create a sample index.html file in the Document Root directory

You can also put your test or development website here for testing. Or you can create an HTML page that shows the links to your files, music, videos, etc. You can also place your files or documents directly in the Document Root folder.


Step 2: Install Apache HTTP Server Client on your Windows PC

Now, download the Apache server client on your PC. After downloading, launch the setup file. Click Next and follow the on-screen instructions.

Apache Http Server Installation Wizard
Apache HTTP Server installation wizard

On the Server Information page, set parameters for Network Domain, Server Name, and Administrator’s Email Address.

In this tutorial, we have used “myserver.com” as the Network Domain, “www.myserver.com” as the Server Name, and “[email protected]” as the email address.

You can configure your details here to set up your web server on your Windows PC.

Enter Server Information And Click Next to setup or host web server on your windows pc
Enter Server information and click Next

Now, complete the rest of the steps and click Finish to exit the installation wizard.

Click Finish To Exit Installation Wizard
Click Finish to exit the installation wizard

Step 3: Configure “httpd.conf” to Set up your Web Server

After you have installed the Apache server client, go to the directory where you installed it (i.e. C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf). Here, you will find an “httpd.conf” file. This file holds the configuration of your website. We will have to change its settings as per our requirements.

But to make changes to httpd.conf file, you need to take its ownership first, otherwise you will not be able to modify it. After taking ownership of the httpd.conf file, open it with Notepad.

We need to change 3 things in httpd.conf file.

  1. First, replace DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" with DocumentRoot "D:\MyServer".
  2. Next, find <Directory "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs"> and replace it with <Directory "D:\MyServer">.
  3. After that, find AllowOverride None and change it to AllowOverride All.

Now, press Ctrl + S  to save changes to the file and close the notepad. Finally, you are ready to set up or host your website on your web server on a Windows PC.

Configure Httpd Conf File Change Document Root And Allow Override All to setup and host web server on windows pc
Configure httpd.conf file

Step 4: Configure Hosts File to Resolve Domain Name

As we have configured myserver.com as the domain name for our website, we need to make it resolvable via the hosts file. We can easily do it by making an entry in the hosts file. So, go to C:\Windows\System32\drivers\etc folder and open hosts file with notepad.

Make sure to take ownership of the hosts file before making changes to it, otherwise, you won’t be able to save the changes. After that, add the following line to hosts file and save it.

127.0.0.1   myserver.com   www.myserver.com

Here, 127.0.0.1 is the loopback address. “myserver.com” and “www.myserver.com” are the domain names of our web server.

Make Hosts File Entry To Resolve Your Custom Domain
Make hosts file entry to resolve your domain

SEE ALSO: How to Configure Proxy on Windows 10?


Step 5: Browse your Web Server via Web Browser

Now, your web server is set up and ready on your Windows PC. You can test it. Type myserver.com or www.myserver.com in your web browser. You can also type your IP Address in your web browser’s address bar. If you have configured everything correctly, you should see the index.html file that you created in Step 1.

Browse Your Website In Your Browser Using Provide Domain - host and configure web server on windows pc
Browse your website in the web browser

Besides using index.html file, you can also put your files and documents directly in the Document Root folder (“D:\MyServer” folder in our case). If there is no index.html file, the browser will display the content of the Document Root folder as shown below.

Put Files And Documents In The Document Root Folder To Access Via Web Server
Browse files and documents in the Document Root folder

Step 6: Access your Web Server Over the Internet

If you want to access your server from other computers via the internet, you must open a port in the router you’re using. You would also need to get a fixed public IP address from your ISP so that your public IP address doesn’t change randomly.

The port we need to forward is port number 80. Why? Because by default it’s the port used for HTTP protocol. Port forwarding means opening a tunnel through the router so that the router won’t reject the connections that are trying to connect to it.

How to port-forward? With every router it’s different. You can find here the instructions for almost every one of them. Besides that, you must also turn off your firewall or allow the Apache server program through your firewall.

Once you have forwarded the HTTP port in your router, you can access your files via web server over the internet. This time you have to put your WAN or public IP in the address bar of your web browser instead of myserver.com or LAN IP.

How to find your WAN IP? You can easily find your WAN IP in your router’s settings or simply type “what is my IP” in Google and it will show your WAN IP. Make sure to avail of the FIXED IP service as your WAN or public IP keeps changing.

NOTE: Please note that your computer must be ON all the time to be accessible via Internet. If you can’t keep it always ON, you can try Wake-on-LAN to turn it ON when required.


SEE ALSO: How to Host a Minecraft Server on your Android Phone?

Setup your Web Server and Host your Website on a Windows PC

The above tutorial explained, how you can easily set up and configure a web server on your Windows PC and host your website. We have explained a very basic web server setup. If you are willing to host a fully functional PHP or WordPress website, you may consider using WampServer instead.

Hope, you liked this tutorial. Feel free to share your thoughts and suggestions with us in the comment section below. You may also subscribe to our newsletter to get the latest updates via email.

Editorial Staff

Hi there, we are the editorial staff at WINDOSPC (former HELLPC). We are a team of funny and technical people. Feel free to get in touch with us via Contact-Us page.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.