Hosting Multiple Websites In IIS
IIS comes with a default website. We know that. Now you want to create multiple websites, right?
No worries, I got you convert.
This is the default website:
We are going to create four websites. Each with an “index.html” with a <h1>Website Number “NUMBER”</h1>.
- Website 1: with and “index.html” that displays “Website Number 1”.
- Website 2: with and “index.html” that displays “Website Number 2”.
- Website 3: with and “index.html” that displays “Website Number 3”.
- Website 4 : with and “index.html” that displays “Website Number 4”.
After creating the scaffolding for each website, the very first thing you have to do is to create an Application Pool for each website. Go to the IIS Manager > Application Pool and on the “Actions” pane click “Add Application Pool”.
Create an Application Pool with the name of your website + “AppPool” or some other standard, but you must know which application pool corresponds to each website. Remember that we are setting an Application Pool for each website so that they have their own pool of resources.
The “Managed pipeline mode” has two options:
A) Integrated: Provides faster execution of ASP.NET code.
B) Classic: Appropriate for older application written for IIS 6.
Now we need to create the Site here in IIS. Go to Sites, right click and “Add Website”.
Give it a name, select its corresponding Application Pool and now we have to face the binding options:
These four fields (type, IP address, port and host name) form a unique identifier. Meaning no two websites can have the same bindings, otherwise how could IIS know which site to display?
It is recommended to have a bindings file. As for now, mine looks like this:
So, in order to add “Website1” we need to modify at least one field. I am going to modify the host name:
Now my binding file looks like this:
Now go to Website1 and browse it:
Hmmm… can’t reach this page right? That is normal. Yes, we changed the host name, but we never specified that this host name corresponds to an IP address.
We will fix this later. Let’s now create the Application Pools and sites for our remaining websites.
For each website you are going to:
- Create an Application Pool.
- Create the corresponding website and make each host name unique.
We now have the following:
Remember that each website should have its own Application Pool.
Our bindings file now looks like this:
But we still have an issue, we are missing the record where we point our IP Address to these host names! For that we can do a little “hack” as we are just messing around, and we actually do not have a domain name.
Open the “host” file with notepad and type your IP Address, press tab and then the host name. Do this for each website:
“host” file located at:
Go to each website in the IIS Manager and click Browse. They all should be working:
If you are having problems, it could be with your bindings, or that you put the wrong IP address. Another common issue might be that you did not name the file as “index.html”. In this case you can either rename it or you can go to the “Default Document” module for each website and add the name of your file, so it gets displays as the default document. You will have to do this for each website that has another name other than the ones specified at the “Default Document” module.
- IIS can manage multiple websites.
- Each Website should have a designated Application Pool.
- The fields in the binding options (type, IP address, port and hostname) form a unique identifier. No two websites can have the same four values.
- In the host file, located at “C:\Windows\System32\drivers\etc”, you will have to map your IP Address to the host name.
- A bindings file helps tracking and managing bindings.