新闻中心

如何从命令行运行IIS Express?

发布时间:2018-08-16 18:08:23

最近一些用户来咨询IIS Express方面的问题,问我们如何用命令行使用IIS Express运行站点的问题,今天小编特意整理了一些从命令行运行IIS Express的方法,前提是服务器安装Windows 7或更高版本以及IIS Express。

 

从命令行使用IIS Express运行站点

 

1.打开命令提示符

您无需管理员用户权限即可运行本演练中的命令。但是,如果要在编号为1024或更小的端口上运行IIS Express,则必须具有管理员用户权限。

 

2.运行以下命令以导航到IIS Express安装文件夹:

cd \Program Files\IIS Express

或者如果您使用的是64位操作系统,请运行以下命令:

cd \Program Files (x86)\IIS Express

 

3.运行以下命令以查看IIS Express用法字符串:

 

iisexpress /?

 

IIS Express Usage:

------------------

iisexpress [/config:config-file] [/site:site-name] [/siteid:site-id] [/systray:boolean]

iisexpress /path:app-path [/port:port-number] [/clr:clr-version] [/systray:boolean]

 

/config:config-file

The full path to the applicationhost.config file. The default value is the IISExpress8\config\applicationhost.config file that is located in the user's Documents folder.

 

/site:site-name

The name of the site to launch, as described in the applicationhost.config file.

 

/siteid:site-id

The ID of the site to launch, as described in the applicationhost.config file.

 

/path:app-path

The full physical path of the application to run. You cannot combine this option with the /config and related options.

 

/port:port-number

The port to which the application will bind. The default value is 8080. You must also specify the /path option.

 

/clr:clr-version The .NET Framework version (e.g. v2.0) to use to run the application. The default value is v4.0. You must also specify the /path option.

 

/systray:boolean

Enables or disables the system tray application. The default value is true.

 

/trace:debug-trace-level

Valid values are info or i,warning or w,error or e.

 

Examples:

iisexpress /site:WebSite1

This command runs WebSite1 site from the user profile configuration file.

 

iisexpress /config:c:\myconfig\applicationhost.config

This command runs the first site in the specified configuration file.

 

iisexpress /path:c:\myapp\ /port:80

This command runs the site from c:\myapp folder over port 80.

 

4.使用以下方法之一运行您的站点:

 

使用/ config从配置文件运行站点。

有关详细信息,请参阅“从配置文件运行站点”。

使用/ path从应用程序文件夹运行站点。

有关详细信息,请参阅“从应用程序文件夹运行站点”。

注意:无法组合/ path选项和/ config选项。

 

5.站点运行后,您可以使用IIS Express系统托盘进行管理。有关更多信息,请参阅使用Windows系统托盘管理网站和应用程序。或者,您可以通过运行以下选项来禁用系统托盘:

/systray:false

 

从配置文件运行您的站点

 

IIS Express和IIS使用ApplicationHost.config文件,该文件指定站点,应用程序池,处理程序等的全局设置.IIS Express使用默认的,特定于用户的ApplicationHost.config文件,允许许多用户共享同一台计算机而不会干扰其他用户的设置。此文件位于%userprofile%\ Documents \ IISExpress \ config文件夹或%userprofile%\ My Documents \ IISExpress \ config文件夹中,具体取决于您的操作系统。从配置文件运行站点时,可以指定要运行的站点。

 

您可以使用以下命令:

要在默认配置文件中运行Website1网站,请运行:

iisexpress /site:WebSite1

 

要在默认配置文件中运行第一个网站,请运行:

Iisexpress

 

要在自定义配置文件中运行第一个网站,请运行:

iisexpress /config:c:\myconfig\applicationhost.config

 

要从自定义配置文件运行名为MyBlog的站点,请运行:

iisexpress /config:c:\myconfig\applicationhost.config /site:MyBlog

 

注意:/ config选项指定配置文件的完整路径。如果要使用默认配置文件,可以省略此选项。/ site选项指定配置文件中的特定站点。您可以省略此选项以在配置文件中运行第一个站点。

 

从应用程序文件夹运行您的站点

您还可以使用/ path选项直接从文件夹运行站点。此选项适用于任何类型的应用程序,包括静态HTML,ASP.NET,PHP和WCF。默认情况下,IIS Express将在http:// localhost:8080 /上运行该站点。对于托管网站(如ASP.NET),IIS Express将使用.NET 4.0。您可以使用/ port和/ clr选项覆盖这些默认值。

 

例如,以下命令使用.NET 2.0 在http:// localhost:9090 /上运行指定的应用程序“myapp” :

iisexpress /path:c:\myapp\ /port:9090 /clr:v2.0


本文由网时云(http://www.abcde.com.cn/)原创首发,转载请以链接形式标明本文地址或注明文章出处!

常见问题

一站式云服务器/BGP高防/站群/免备案服务器平台 提供高防服务器租用、托管服务!

深圳市龙华大道553号光浩国际中心A座七楼南区
4008-650-660
4008-650-660
sc@abcde.cn
深圳总部:深圳市龙华大道553号光浩国际中心A座七楼南区 电话:0755-88850505
广州分部:广州市天河区燕岭路120号金燕大厦9楼913 电话:020-86000435
Copyright © 2013-2021 网时云版权所有 | 香港网时集团运营,深圳市原创科技有限公司售后支持