Recipe12.4.Hosting Multiple Web Sites


Recipe 12.4. Hosting Multiple Web Sites

Problem

You want to host multiple web sites on the same computer.

Solution

Using a graphical user interface

To uniquely identify each web site by IP address:

  1. Start the Web Site Creation Wizard described in the previous recipe.

  2. When the IP Address and Port Settings screen appears, select any unused IP address from the list and continue with the wizard.

  3. Users can now access each site using URLs such as http://172.16.12.50, http://172.15.12.51, and so on. You can also use a DNS server to define friendly DNS names for each site if desired.

To uniquely identify each web site by port number:

  1. Start the Web Site Creation Wizard described in the previous recipe.

  2. When the IP Address and Port Settings screen appears, specify any port number above 1023 and continue with the wizard.

  3. Users can now access each site using an URL such as http://172.16.12.50:8081, http://172.16.12.50:8082, and so on. You can also use a DNS server to define a friendly DNS name for your server, but users will still need to know the port number for each site they want to access, for example http://www.mtit.com:8081, http://www.mtit.com:8082, and so on.

To uniquely identify each web site by host header name:

  1. Start the Web Site Creation Wizard described in the previous recipe.

  2. When the IP Address and Port Settings screen appears, type a unique host header name for the site and continue with the wizard.

  3. Users can now access the web site with host header name www1.mtit.com using the URL http://www1.mtit.com, the web site with host header name www2.mtit.com using the URL http://www2.mtit.com, and so on.

You can also modify the IP address or port number of an existing web site, or assign it a host header name, by doing the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the Web Sites node under the server node.

  3. Right-click on the node for the web site you want to configure and select Properties.

  4. Select the Web Site tab.

  5. Change the IP address assigned to the site if desired.

  6. Change the default port number (80) to something different if desired.

  7. Click Advanced, click Add, and specify a host header if desired (you can repeat to assign multiple host headers for your site).

Using a command-line interface

The following commands create two web sites on the local server that are uniquely identified by IP addresses:

> iisweb /create D:\HR "Human Resources" /i 172.16.12.51 > iisweb /create D:\Finance "Accounting Department" /i 172.16.12.52

The following commands create two web sites on the local server that are uniquely identified by port numbers (the first site uses the default port 80):

> iisweb /create D:\HR "Human Resources" /i 172.16.12.50 > iisweb /create D:\Finance "Accounting Department" /b 8080 /i 172.16.12.50

The following commands create two web sites that are uniquely identified by their host header names:

> iisweb /create D:\HR "Human Resources" /i 172.16.12.50 /d hr.mtit.com > iisweb /create D:\Finance "Accounting Department" /i 172.16.12.50 /d acct.mtit.com

To list all web sites on the local server, use the following command:

> iisweb /query

Using VBScript
' This code displays all the web sites on a server. ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" ' e.g., web01.rallencorp.com ' ------ END CONFIGURATION --------- set objIIS = GetObject("IIS://" & strComputer & "/W3SVC") for each objSite in objIIS    if (objSite.Class = "IIsWebServer") then       WScript.Echo objSite.ServerComment & " (" & objSite.Name & ")"    end if next

Discussion

The maximum number of web sites you can create on an IIS 6 computer depends on the available RAM. For example, a computer with 256 MB of RAM can host only 64 sites, and if you try to create a 65th site you'll get error 1131 in the System event log. In lieu of adding more RAM, you can work around this limitation by creating a new DWORD value named MaxEndPoints in the following registry key:

HKLM\SYSTEM\CurrentControlSet\Services\HTTP\Parameters

Set MaxEndPoints to one more than the number of web sites you need to host, but don't exceed 1024.

The web site limitation based on RAM is in place for a good reason. Microsoft does this so they can count on a certain amount of RAM per web site. Unless you have a good reason and you really know what you're doing, it probably doesn't make sense to mess around with the MaxEndPoints key.


Using VBScript

This code works by obtaining a reference to the top-level IIS service (W3SVC), enumerating all of the child objects, and printing the child objects of the class IIsWebServer, which represent web sites. The W3SVC object can also have IIsWebInfo and IIsFilter child objects, so if you don't check for the IIsWebServer class, you may end up printing more than just web sites.

See Also

Recipe 12.3 and MS KB 324287 (HOW TO: Use Host Header Names to Configure Multiple Web Sites in Internet Information Services 6.0)



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net