Internet Information Services (IIS) is included with each version of the Windows operating system. It might not be installed by default, but unless you run a very old version of Windows, you have IIS installed. IIS is Microsoft’s web hosting software, so having it installed gives you the ability to run a website on your machine.
An Overview of IIS
Even if you don’t host your own website, you might need to know IIS to test a website you’re programming. You can set up IIS to host a website locally, so you can test it before uploading it to a public-facing server. Even desktop versions of Windows have IIS, so you can run IIS on your local development machine.
The main IIS configuration utility is found in the Windows Control Panel. It’s in the “System and Security” section in the “Administrative Tools” option. The below image gives you a quick overview of the IIS 7.5 main manager window:
There are several IIS utilities to configure your website. You won’t use many of these utilities at all. The main utilities to create a website are the following:
- Default Document
- Connection Strings
- Error Pages
The utilities and settings you use are dependent on the website. If this is your first website and the first time you’ve used IIS, then most of the utilities don’t need editing. The default values are enough to host a beginner website.
Configuring Your Website
Unless you have a separate IP for your website, you’ll probably need to host multiple sites on one IP address. If you’re using IIS to test a website on your local machine, you can use the “Default Web Site” listed under “Sites.”
To run a website on the same IP (in this case it will be “localhost” which is Windows’ way to identify the local machine), you must set your new website up as a new application.
Right-click “Default Web Site” and select “Add Application.” You’ll need to name your application and point to the folder that contains your website code. You also choose an application pool. An application pool is a separate worker space that lets your website run separately from others. This means that you can reboot, edit and stop an application pool and only this particular website is affected. Application pools let you run websites in different server processes, so other websites do not affect your application.
After you’ve created your application, it will show up under “Default Web Site.” To view your site, right-click the new application, click “Manage Application” and then “Browse.” As long as you aren’t blocking the folder with permissions and you have a default document set, you’ll see your website’s home page.
For a very basic website, this is all you need to do to run it on your computer. If you type “localhost/<<appname>>” in your browser, you can run the site as if it was running at a web host. However, you probably need to edit some of the settings.
The default document is the web page that loads when the user types just your domain name into the browser. The default document is usually index.html for a static site or default.aspx for web forms. If you’re running an MVC site, you don’t need to set a default web page in IIS. The MVC engine handles this for you and uses the home view as the default home page.
Double-click the “Default Document” icon in IIS. A list of page names is shown. There are usually four default documents set up in IIS. If you don’t use them, you can delete all of them except the one you need. IIS looks for the first document listed, and if it can’t find the first default document, it moves to the next one and so on. If you have no documents listed, IIS will throw an error.
Connection strings define database connections. Each type of connection string is determined by the database your website is connecting to. For instance, if you’re connecting to a SQL Server database, the connection string indicates that the driver type is SQL, tells the application which database and server to connect to and any user names and passwords needed to connect to the server. You can set the connection string in IIS or in the application. Most applications set the connection string in the application code.
Every server needs logs. IIS is no different. IIS has a “Logging” section where you can read and alter your log settings.
First, you can create one log for all sites or a log for each site. For convenience, it’s better to keep one log for each site. This lets you more easily find issues with your site, and it lets you find certain IPs and block suspicious behavior.
You can also set the location for your logs, although IIS keeps them by default in the “inetpub” directory. If you ever need to research issues, you can look in these logs.
When your server throws an error, you need a page to display to the user. Common errors are 404s (page not found), 403 (permission denied), and 500 (general error) errors. Instead of losing traffic to these basic errors, you can create custom pages to display to the user.
You can customize these pages with something other than the default. For instance, you can create a 404 page that points to other locations in your website, so the user can find an alternative instead of losing the user due to a broken page.
IIS is much different than Apache, but its user interface makes it easy to set up a website. If you’re in charge of a Windows host environment, you’ll need to know how to create a website.