【发布时间】:2014-01-29 11:38:55
【问题描述】:
问题/疑问
我正在测试运行用于 redgate 部署的脚本。在最后一步,它会启动一个网站:
import-module WebAdministration
$website = get-website | where-object { $_.name -eq $RedGateWebSiteName }
#(re)write HostName#
$binding = Get-WebBinding -Name $RedGateWebSiteName
Set-WebBinding -Name $RedGateWebSiteName -BindingInformation "*:80:*" -PropertyName HostHeader -Value $HostName
if ($website) {
Start-Website "$RedGateWebSiteName"
}
它总是有效,但现在在最后几天我收到此错误
At D:\inetpub\Timeblockr-RedGate\Api\PostDeploy.ps1:15 char:15
+ Start-Website <<<< "$RedGateWebSiteName"
+ CategoryInfo : InvalidOperation: (:) [Start-Website], COMException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand
IIS 错误
The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:80/ for site 3. The necessary network binding may already be in use. The site has been disabled. The data field contains the error number.
这个 SO 问题"Cannot create a file" error when running Start-Website command in Powershell 提供了一个很好的线索。
编辑:
查看我的事件日志并检查答案后,我发现当 Redgate 自动尝试安装/启动网站时,我收到了这个 IIS 错误:
The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:80/ for site 3. The necessary network binding may already be in use. The site has been disabled. The data field contains the error number.
在此 Serverfault 中:https://serverfault.com/questions/456217/the-world-wide-web-publishing-service-www-service-did-not-register-the-url 有人提到其原因是在没有主机头的情况下创建了 IIS 网站。尝试启动网站后,我正在添加主机头。让我们找到解决方案
编辑 2:
我在尝试启动网站后添加了主机名。这导致该网站的主机名为空,并且在 IIS 中发生冲突。 (或者别的地方)。
我更改了脚本以获取网站,添加主机名,然后启动网站。
还添加了“$RedgateWebsiteName" 而不是 $RedGateWebSiteName. 现在完美运行!
编辑 3: 经过一系列测试后,我似乎最终遇到了同样的错误。一个部署没有问题,另一个部署确实有。
编辑 4: 我已经更新了脚本/错误/发布。 在我点击安装之后,我从 IIS 中删除了我的网站。完美安装 - 没有问题,自动启动。 第二次运行完全一样,第三次运行我得到上面的错误!
【问题讨论】:
-
可以通过 UI 启动网站吗?
-
@DavidMartin 是的,效果很好。
标签: iis powershell redgate