【问题标题】:Adding site and bindings (with Host Name, Port, and IP Address) to IIS with appcmd使用 appcmd 将站点和绑定(使用主机名、端口和 IP 地址)添加到 IIS
【发布时间】:2016-01-29 18:54:15
【问题描述】:

我正在尝试使用 appcmd.exe 将网站添加到 IIS。

除了一个小错误,我几乎所有东西都可以工作。

我正在使用的代码行是

add site /name:WEBSITENAME /bindings:https://HOSTNAME:10.100.213.121:443 /physicalpath:C:\inetpub\WEBSITENAME

当我这样做并查看 IIS 上的绑定时,除了我的 ip 地址显示为“*:10.100.213.121”(不包括引号)之外,一切都正确无误

它在某处添加 *: 到它的开头。

这正在创建一个无效的绑定。

我想只保留一个命令

我知道我可以使用第二个命令来编辑站点绑定,但如果我可以保留这一切,那么创建站点将是理想的

【问题讨论】:

    标签: iis cmd appcmd


    【解决方案1】:

    您的 bindings 参数可能存在语法问题,请注意这也表明问题的答案:

    根据reference documentation的bindings参数可以按以下格式传递:

    /bindings:http/*:85: -- note single slash after protocol
    

    您的示例表明使用了以下格式。

    /bindings:http//*:85: -- note the extra forward slash after the protocol.
    

    因此:

    选项 1

    将任务作为单个命令执行:

     appcmd add site /name:WEBSITENAME /physicalpath:C:\inetpub\WEBSITENAME /bindings:https/10.100.213.121:443:
    

    选项 2

    将任务作为两阶段提交执行。

    1. 创建站点(您已有的内容的变体减去绑定信息)

    2. 应用所需的绑定配置更改。

    此示例中两阶段提交的原因是由于第二个命令要求站点在应用配置更改之前存在。

    注意:这两个命令在命令行中用 & 分隔,因此它们可以作为一行运行。

    appcmd add site /name:WEBSITENAME /physicalpath:C:\inetpub\WEBSITENAME & appcmd.exe set config  -section:system.applicationHost/sites /+"[name='WEBSITENAME'].bindings.[protocol='https',bindingInformation='10.100.213.121:443:']" /commit:apphost
    

    Additional Documentation

    【讨论】:

      【解决方案2】:

      见下文我如何使用 SSL 端口 443

      appcmd 设置站点 /site.name:NAME_SITE_IIS /+bindings.[protocol='https',bindingInformation='*:443:yourdomain.com.br' ]

      粗体处,更改信息

      【讨论】:

        【解决方案3】:

        我现在测试它如下,它工作。

        appcmd add site /name:test.com /physicalPath:C:\inetpub\wwwroot\test.com /bindings:http/192.168.0.1:80:test.com
        

        希望对你有帮助。

        【讨论】:

          猜你喜欢
          • 2014-03-25
          • 2023-02-04
          • 2021-12-11
          • 1970-01-01
          • 2018-09-23
          • 1970-01-01
          • 1970-01-01
          • 2014-03-09
          • 2017-04-28
          相关资源
          最近更新 更多