Cooking with Windows Server, Part 2
by Robbie AllenIn 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:
-
Open Internet Information Services (IIS) Manager.
-
In the left pane, expand the server node.
-
Right-click on the Web Sites node, select New → Web Site to start the Web SiteCreation Wizard, and click Next.
-
Type a descriptive name for your site and click Next.
-
Assign an IP address to your site and click Next.
-
Specify the path to the home directory for your site, decide whether to allow anonymous access to your site, and click Next.
-
Specify web permissions to control access to your site and click Next, then Finish.
|
Related Reading
Windows Server Cookbook |
To create a new web site using a previously saved configuration file, do the following:
-
Open Internet Information Services (IIS) Manager.
-
In the left pane, expand the server node.
-
Right-click on the Web Sites node and select New → Web Site (from file).
-
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.
-
If the saved configuration was password protected when it was created, you'll be prompted here for a password; enter it and click OK.
-
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

