In this blog, we are going to show you how to host a website in IIS on Microsoft Windows Server. For demo purposes, I have created folder called DemoSite in C:\inetpub\wwwroot . This is the default folder for IIS access. You can also chose any other folder or location.
In this DemoSite folder, I created a simple html page with notepad and added the following content:
<html>
<head>
</head>
<body>
<H1>This is my heading in demo site</H1>
<P>This is my paragraph in demo site</P>
</body>
</html>
Now, we have created very simple webpage which we’ll be hosting on IIS server so it can be served to the clients trying to access this page.
Follow the steps below to host this simple website in IIS.
Step 1 Go to Start and type IIS
Step 2 Open Internet Information Services (IIS) Manager app and expand Sites.
You can see currently we have a Default Web Site which has been created by IIS after installation.
Step 3 Right Click on Sites and click Add Website
Once Add Website has been clicked, a new popup window will open. In this window, we need to provide our DemoSite details as below:
Site name : DemoSite
Physical path : C:\inetpub\wwwroot\DemoSite
Leave rest as they are for now:
Once you have added the information click OK.
You might get a message as below:
Click Yes for now.
Step 4 Once you click Yes, you’ll see a new website would have been added in the IIS panel on the left under Sites:
Currently it is showing as stopped. The reason it is stopped is that we are already using port number 80 for Default Web Site and IIS does not allow to run multiple sites on the same port. We’ll cover this this in more detail in IIS bindings.
So for now we’ll either delete or stop Default Web Site instead.
Step 5 Stop IIS Default Web Site
Step 6 Start our newly added DemoSite
This time you’ll not get any message and site should be started straight away.
Congratulations, we have hosted a simple website in IIS.
Verification
Now let’s try to browse our site and see if we can browse and the content we added in demo.html is dispaying correctly.
Step 7 On the right pane (Actions) in IIS Manager you’ll see an option to browse this site on port 80 as per screen below:
Click on Browse *.80 (http) and you’ll see the web site opening in a new webpage.
You might find an error below when you click on browse.
The reason this is coming is that when IIS is installed, it only renders and tries to find the following files with its Default Document settings.
We have created a page in DemoSite with the name as demo.html which is not available in IIS Default Document settings and IIS is not aware of whether to load this page or not so it produces this forbidden error.
In order to fix this we’ll need to add demo.html in IIS Default Document settings.
Let’s do this by going to site settings in the middle pane in IIS. You’ll find Default Document option for this site, double click on this.
It’ll take you to the Default Document settings page. This is where you’ll set the list of all the default documents configured to run on this site. All of the files below are inherited from the server global settings which are available to each newly site created in IIS.
We’ll have to add demo.html in this list so when this site is being accessed, our demo.html page should load. We can remove the rest of the documents if we want to but we’ll leave them there for now but add demo.html to this list.
In the Actions pane on the right, click Add.
In the new window, enter demo.html in the Name field and hit OK.
Once added you’ll see the demo.html in the Default Document list now which is local only to our DemoSite. It’s not available to any other site hosted in our IIS instance.
Once this is done go back to the site browse it again or refresh the previous forbidden error page, it should show our HTML content now.