WindowsDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


AddThis Social Bookmark Button O'Reilly Book Excerpts: Windows Server Cookbook

Cooking with Windows Server, Part 2

by Robbie Allen

In this excerpt from Robbie Allen's Windows Server Cookbook, Robbie shows you how to build Web sites and how to mailbox-enable users.

Creating Web Sites

Problem

You want to create a web site.

Solution

Using a Graphical User Interface

To create a new web site from scratch using a wizard, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the server node.

  3. Right-click on the Web Sites node, select NewWeb Site to start the Web SiteCreation Wizard, and click Next.

  4. Type a descriptive name for your site and click Next.

  5. Assign an IP address to your site and click Next.

  6. Related Reading

    Windows Server Cookbook
    For Windows Server 2003 & Windows 2000
    By Robbie Allen

  7. Specify the path to the home directory for your site, decide whether to allow anonymous access to your site, and click Next.

  8. Specify web permissions to control access to your site and click Next, then Finish.

To create a new web site using a previously saved configuration file, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the server node.

  3. Right-click on the Web Sites node and select NewWeb Site (from file).

  4. Specify the path to the XML file containing your saved IIS configuration, click Read File, select the web site you want to import, and click OK.

  5. If the saved configuration was password protected when it was created, you'll be prompted here for a password; enter it and click OK.

  6. Right-click on the new web site and select Start.

Using a Command-Line Interface

The following command creates a new web site named Human Resources on server with IP 216.44.65.8 and root directory D:\HR:

> iisweb /create D:\HR "Human Resources" /i 216.44.65.8

The following command creates a new site named My Company with root directory D:\Corp and IP address "All Unassigned," effectively making My Company the new default web site on the server:

> iisweb /create D:\Corp "My Company"

The following command creates a site on a standalone server named web04 using local credentials for that computer and leaving the site in a stopped state:

> iisweb /create D:\Finance "Accounting Department" /i 216.44.65.8 
/dontstart /s web01 /u web04\Administrator /p <password>

The following command creates a site by importing a previously saved password-protected site configuration file named hr.xml:

> iiscnfg /import /f D:\hr.xml /d <password> /sp /lm/w3svc/1525757177 
/dp /lm/w3svc/2/child

The ID number 1525757177 for this site can be found by opening the XML file in Notepad and examining the Location attribute of the IisWebServer tag. For example:

<IIsWebServer    Location ="/LM/W3SVC/1525757177"
        AuthFlags="0"
        ServerAutoStart="TRUE"
        ServerBindings="172.16.12.50:80:"
        ServerComment="Human Resources"
    >
</IIsWebServer>

TIP: You can also retrieve this identifier from IIS Manager by clicking the Web Sites folder in the left pane. The list of web sites and their identifiers will be shown in the right pane.

Using VBScript

' This code creates a web site.
' ------ SCRIPT CONFIGURATION ------
strComputer = "<ServerName>" ' computer to connect to
strSiteName = "<SiteName>"   ' web site description
strRootDir = "<DirPath>"     ' root directory for the web site
' The following parameters are optional
' strPort = "<PortNumber>"     ' port for the web site
' strIP = "<IPAddress>"        ' IP address used for the site
' strHostHeader = "<HostName>" ' host header name for the site
' strSiteID = 1234             ' site ID (default is to auto-generate)
' ------ END CONFIGURATION ---------
set objIIS = GetObject("IIS://" & strComputer & "/W3SVC" )
objServerBindings = Array(0)
objServerBindings(0) = strIP & ":" & strPort & ":" & strHostHeader
strNewSiteID = objIIS.CreateNewSite(strSiteName, objServerBindings, _
                                    strRootDir, strSiteID)
WScript.Echo "Successfully created web site " & strSiteName & _
             " with ID " & strNewSiteID

Pages: 1, 2, 3

Next Pagearrow