How to Setup 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 runs on web servers. So, if you wish, you can also setup a web server on your Windows PC and host your own website there. That’s right, you can create your own web server using Apache client.

There may be several reasons to create your own web server. For example- file sharing or create a web site on your own computer. In simple terms, you choose a directory on your computer and put files like music, video 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 and you can also download those files.

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

Setup a Web Server on your Windows PC using Apache Client

For creating your own web server, you need 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. And if you wish to access your server from internet, you also need active internet connection with fixed public IP address and port forwarding.

Step 1: Create Document Directory and Default Page for 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 index.html file when you type website address in browser.

Create Sample Index.html File And Place It In Your Document Root Directory of your web server apache
Create sample index.html file in 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 or videos etc. You can also place your files or documents directly in Document Root folder.


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

Now, download Apache server client on your PC. After downloading, launch the setup file. Click Next and follow 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 Network Domain, www.myserver.com as Server Name and [email protected] as email address. You can configure your own details here to setup your own 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 rest of the steps and click Finish to exit installation wizard.

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

Step 3: Configure httpd.conf to Setup your Web Server

After you have installed Apache server client, go to 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 it’s settings as per our requirements.

But in order to make changes to httpd.conf file, you need to take it’s ownership first, otherwise you will not be able to modify it. After taking ownership of 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 file and close the notepad. Finally, you are ready to setup or host your website on your own web server on 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 domain name for our website, we need to make it resolvable via 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 hosts file before making changes to it, otherwise, you won’t be able to save the changes. After that, add following line to hosts file and save it.

127.0.0.1   myserver.com   www.myserver.com

Here, 127.0.0.1 is loopback address and myserver.com and www.myserver.com are 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 setup 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 your 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 web browser

Besides using index.html file, you can also put your files and documents directly in Document Root folder (“D:\MyServer” folder in our case). If there is no index.html file, the browser will display the content of 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 own server from other computers via internet, you must forward 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 actually means opening a tunnel through the router so that the router wouldn’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 you firewall or allow Apache server program through your firewall.

Once you have forwarded 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 you have availed 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 Windows PC

Above tutorial explained, how you can easily setup and configure web server on your Windows PC and host your own 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 down below. You may also subscribe to our newsletter to get 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.

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

Back to top button