An Introduction to IIS: WWW Service Setup

You have setup WWW Services so what now. In this section we are going to get familiar with some of the functionality in Microsoft Management Console which allows us to configure our WWW Service. Okay enough chat lets get started…

There are two options to configure WWW Service either using Internet Information Service Manager (under Control Panel -> Administrative Tools) or Microsoft Management Console. You can access these tools through command line by either typing inetmgr for IIS Manger or mmc for Microsoft Management Console. It really does not matter which one of these tools you use, they both “have same functionality” however Microsoft prefers you to use MMC ’cause it is moving towards that direction to configure all your services. Do not worry, if you do not know how to use MMC, I have created a tutorial for that which you can find under IIS category.

Here is a screen snap of my MMC in action.
Microsoft Management Console

…Again do not worry if you are not familiar with MMC, there is a tutorial for it.

Topics we are going to be covering are

  • Web Site Tab
  • Home Directory Tab
  • Security Tab
  • Custom Errors Tab
  • HTTP Headers Tab
  • Documents and Operators Tab
  • ISAPI Tab
  • Making Virtual Directory

Web Site Tab

1./ In your Scope Pane right click on “Default Web Site” for Properties

Default website properties

Default website properties dialog

On this tab we are going to take a look at some of the items.
1.1./ Web Site Identification
1.1.1./ Description: This field displays the description of the website that appears on our MMC. On this occasion it is set to “Default Web Site”, if we change it to… lets say “Website 1″… and then press “Apply”, the website description changes on our MMC.

Website description

1.1.2./ IP Address: This list the IP addresses of your net cards. One my machine, I have one net card so it lists just the one. At this time, I have set it to my IP address, so yours may be different

Web site identification ip-address

1.1.3./ Advanced: This button give us further configuration options to change IP addresses and default ports for browser and ssl socket

Web site identification advanced options

1.1.4./ TCP Port: this specifies which port to connect to during a browser request by default it is port 80 however you can specify it to some thing other than 80 which you then have to specify on your web browser. For this instance we are going to leave it as it is.

Web site identification TCP port

1.2./ Connections
1.2.1./ Connection Timeout: suppose the user is connected however they are not doing anything, you can specify how long to keep the connection open. In this case after 900 sec of idle time, it cuts the user connection.

Connections - Connection timeout

1.2.3./ Unlimited (Option available to Windows 2003 Server) : does what it says. It allow as many users to connect to your website.
1.2.4./ Limited To (Option available to Windows 2003 Server): If your web server resources are limited and you want to restrict the number of users connecting then this option is for you.

1.3./Enable Logging
1.3.1./ Enable Logging: you can have this option switched on or off depending if you want logging information. In this option you have several items they are
1.3.1.1./ Microsoft IIS Log File Format: Microsoft IIS log format is fixed ASCII text-based format which cannot be customised set by Microsoft
1.3.1.2./ NCSA Common Log File Format: It is another fixed ASCII text-based format which cannot be customised set by National Center for Suppercomputing Applications (NCSA)
1.3.1.3./ W3C Extended Log File Format: This is customisable ASCII text-based log format which is the default IIS log format. For our tutorial we are going to select this option.

1.3.2./ Properties: Pressing this button gives us options of when and where to create new log file.
1.3.2.1/ General Properties tab:
1.3.2.1.1./ you can specify when a new log file can be created hourly, daily, weekly, monthly, unlimited file size and when file size reaches a specified size. In our tutorial we are selecting daily.

Extended logging properties

1.3.2.1.2./ Log File Directory: this field allows us to specify a different directory other than the default directory. We are going to leave this on the default directory
1.3.2.2./ Extended Properties tab:
1.3.2.2.1./ This gives us list of items that we can have on our log file. Some of this options are selected for you by default however you can add more by checking the checkbox.

Extended properties tab

Home Directory Tab

2./ Specifies the location of your website directory.
2.1./ A directory located in this computer: this option tells IIS that the the website files are located on this computer.

Home directory tab - connecting to resources on this computer

2.1.1./ Local path: under local path you can define where your web site folder is. your web folder does not need to be Inetpub/wwwroot directory, you can have it any where in your computer as long as you tell IIS where to look for it. On this occasion we are going to leave it on its default settings.
2.1.2./ Permission settings: you have many options here; you can decide to give the client read, write, log visits, directory browsing and indexing. we are going talk about index later so do not worry about it at this instance.
2.1.2.1./ Read: this option gives the client, who is visiting your website to read the files on your website. we need this checked ’cause this is what we want the clients to be able to do.
2.1.2.2./ Write: this option gives the client to edit your script and we do not want that. It is useful to have if you are sharing files over the intranet however not over the internet.
2.1.2.3./ Directory browsing: this option allows clients to browse your server directory. This option needs to be switched off
2.1.2.4./ Log visits: this option logs client visits, we are going to talk about its importance later, for now we are going have this option checked
2.1.2.5./ Index this resource: this option we are going to talk about further later, for now have it checked.

2.2./ A shared located on another computer: if the website files are located on another computer then we can use this option.

Home Directory tab: connecting to resources in another computer

2.3./ A redirection to a URL: this allows to send the client to specified URL where you can select to send the client to the exact URL, directory within the specified URL and a permanent redirection to the URL specified.

Home Directory tab: redirecting to an URL

Directory Security Tab

3./ We need setup our directory security by selecting “Directory Security” on website properties
Directory Security tab: securing directory

3.1./ click on Edit under “Anonymous access and authentication control” and have anonymous access checked. This allows anonymous access which is the default setting on the internet and this is why you are not prompted for authentication when you try to access the website. That is that for now

Custom Error Tab

4./ In this session we are going to look at custom error tab which allows us to display our own message when an error occurs.
4.1./ In website properties, select “Custom Error” tab and select HTTP 404 error.

Directory Security tab: securing directory

4.2./ To edit HTTP error message select an error and click “Edit Properties”. In the new dialog box you can chose to display an alternative message file using the “Browse” button

Directory Security tab: securing directory

… continued

How to setup IIS web server

Yet another installation manual for setting up IIS web server, matter of fact this is 1,070,000th on google search. Anyhoo, lets get on with it.

1./ first log on as the web server user.
2./ go to Start, Control Panel (if you’r Window XP user) and Add/Remove Programs
3./ select Add/Remove Windows Components
Add/Remove Programs
4./ select Internet Information Services (IIS)
5./ press Details… for advance options and select File Transfer Protocol (FTP) Service, SMTP Service and World Wide Web Service
Add/Remove Windows Components. After that press OK.
6./ to finish press next to continue with installation.
7./ you should have a new folder called Inetpub on your primary hard drive (which is C:\ drive).
8./ now type in http://localhost/ on your browser
Add/Remove Windows Components

…you are done.

exercise 1.35 solution

#include <iostream>

using std::cout;
using std::endl;

int main() {
        cout << static_cast<int>('A') << endl;
        cout << static_cast<int>('B') << endl;
        cout << static_cast<int>('C') << endl;
        cout << static_cast<int>('a') << endl;
        cout << static_cast<int>('b') << endl;
        cout << static_cast<int>('c') << endl;
        cout << static_cast<int>('0') << endl;
        cout << static_cast<int>('1') << endl;

        return 0;
}

exercise 1.32 solution

#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main() {
        int number1, number2;

        cout << "Enter first number: ";
        cin >> number1;

        cout << endl << "Enter second number: ";
        cin >> number2;

        if(number1 % number2 == 0) {
                cout << number1 << " is multiple of " << number2 << endl;
        }else{
                cout << number1 << " is not multiple of " << number2 << endl;
        }

        return 0;
}

exercise 1.30 solution

#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main() {
	int num1, num2, num3, num4, num5;

	cout << "Enter first integer: ";
	cin >> num1;

	cout << "\nEnter second integer: ";
	cin >> num2;

	cout << "\nEnter third integer: ";
	cin >> num3;

	cout << "\nEnter fourth integer: ";
	cin >> num4;

	cout << "\nEnter fifth integer: ";
	cin >> num5;

	int largest_num = num1;
	if(largest_num < num2) {
		largest_num = num2;
	}

	if(largest_num < num3) {
		largest_num = num3;
	}

	if(largest_num < num4) {
		largest_num = num4;
	}

	if(largest_num < num5) {
		largest_num = num5;
	}

	cout << "\nlargest number " << largest_num;

	int smallest_num = num1;
	if(smallest_num > num2) {
		smallest_num = num2;
	}

	if(smallest_num > num3) {
		smallest_num = num3;
	}

	if(smallest_num > num4) {
		smallest_num = num4;
	}

	if(smallest_num > num5) {
		smallest_num = num5;
	}

	cout << "\nsmallest number " << smallest_num << endl;

	return 0;
}