命令行安装IIS 7.5

blchen一般都是用Web Platform Installer来在服务器上快速安装IIS,WebPI会自动根据当前的操作系统安装正确的IIS版本( XP=> IIS 5.1,2003=>IIS6,VISTA/2008=> IIS 7.0,WIN7/2008R2 –> IIS7.5),非常之省事。最近遇到一个需求,需要在脚本里安装IIS。于是就研究了一下IIS的自动化安装工具。

VISTA推出后,微软推出了一个命令行工具Windows Package Manager (Pkgmgr.exe)可以用于安装IIS 7,比如如下命令可以在VISTA和Windows Server 2008下从命令行安装IIS 7

pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect

到了Windows 8和Windows Server 2008 R2后,微软做了一些改变,推出了一个新的工具叫Deployment Image Servicing and Management (DISM.exe)。DISM工具提供了更强大的包安装功能,并且还支持安装到没有启动起来的操作系统(比如说mount到某个磁盘的WIM或者VHD文件)。

如下是在命令行下用DISM.exe安装IIS的例子。(注意,命令只有一行)。

dism /Online /Enable-Feature
/FeatureName:IIS-ApplicationDevelopment
/FeatureName:IIS-ASP
/FeatureName:IIS-ASPNET
/FeatureName:IIS-BasicAuthentication
/FeatureName:IIS-CGI
/FeatureName:IIS-ClientCertificateMappingAuthentication
/FeatureName:IIS-CommonHttpFeatures
/FeatureName:IIS-CustomLogging
/FeatureName:IIS-DefaultDocument
/FeatureName:IIS-DigestAuthentication
/FeatureName:IIS-DirectoryBrowsing
/FeatureName:IIS-FTPExtensibility
/FeatureName:IIS-FTPServer
/FeatureName:IIS-FTPSvc
/FeatureName:IIS-HealthAndDiagnostics
/FeatureName:IIS-HostableWebCore
/FeatureName:IIS-HttpCompressionDynamic
/FeatureName:IIS-HttpCompressionStatic
/FeatureName:IIS-HttpErrors
/FeatureName:IIS-HttpLogging
/FeatureName:IIS-HttpRedirect
/FeatureName:IIS-HttpTracing
/FeatureName:IIS-IIS6ManagementCompatibility
/FeatureName:IIS-IISCertificateMappingAuthentication
/FeatureName:IIS-IPSecurity
/FeatureName:IIS-ISAPIExtensions
/FeatureName:IIS-ISAPIFilter
/FeatureName:IIS-LegacyScripts
/FeatureName:IIS-LegacySnapIn
/FeatureName:IIS-LoggingLibraries
/FeatureName:IIS-ManagementConsole
/FeatureName:IIS-ManagementScriptingTools
/FeatureName:IIS-ManagementService
/FeatureName:IIS-Metabase
/FeatureName:IIS-NetFxExtensibility
/FeatureName:IIS-ODBCLogging
/FeatureName:IIS-Performance
/FeatureName:IIS-RequestFiltering
/FeatureName:IIS-RequestMonitor
/FeatureName:IIS-Security
/FeatureName:IIS-ServerSideIncludes
/FeatureName:IIS-StaticContent
/FeatureName:IIS-URLAuthorization
/FeatureName:IIS-WebDAV
/FeatureName:IIS-WebServer
/FeatureName:IIS-WebServerManagementTools
/FeatureName:IIS-WebServerRole
/FeatureName:IIS-WindowsAuthentication
/FeatureName:IIS-WMICompatibility
/FeatureName:WAS-ConfigurationAPI
/FeatureName:WAS-NetFxEnvironment
/FeatureName:WAS-ProcessModel
/FeatureName:WAS-WindowsActivationService

本文参考了Habib Heydarian的博文How to install IIS 7.5 on Windows 7 using the Command Line

Leave a Reply

Your email address will not be published. Required fields are marked *