Managing IIS from the Command Line
In this section, we'll take a look at administering IIS 7 outside of IIS Manager. We'll start by examining some common administrative scenarios through the user of AppCmd.exe, and then look at the text-file configuration options that this new version of IIS presents to us.
AppCmd.exe: One-Stop Configuration
IIS 7 includes AppCmd.exe, which is a new, one-stop executable for administering essentially every function IIS provides. Through AppCmd, you can create and configure sites, application pools, and virtual directories; start, stop, and recycle sites and pools; examine current activities in the core of the web server service; and generally find, copy, and import configurations of both IIS itself and the ASP.NET subcomponent.
AppCmd takes a logical syntax: you perform an operation, or command, on a specific piece of IIS, or an object. For example, you can list sites (list being the command and site being the object), add applications, delete worker processes, or set configurations.
Tip
You can get a general sense of the scope of functions AppCmd supports by using the /?
switch at a command line.
For example, we can list the sites that are stopped on a server by using the following command:
appcmd list sites /state:Stopped
We can add a completely new web site entirely from the command line. Let's add a site named "Booksite" that listens on port 81 and whose content is stored at c:\inetpub\wwwroot\booksite
:
appcmd add site /name:BookSite /id:2 /bindings:"http/*:81:" ...
Get Windows Server 2008: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.