2014-01-10 68 views
3

问题/疑问Powershell的启动IIS网站

我试运行展鹏部署脚本。在最终的步骤启动一个网站:

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. 

这太问题"Cannot create a file" error when running Start-Website command in Powershell给出了一个很好的线索。


编辑:

看我的事件日志,检查出我发现,当展鹏全自动尝试安装/启动网站我得到这个答案后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. 

在这个服务器错误:https://serverfault.com/questions/456217/the-world-wide-web-publishing-service-www-service-did-not-register-the-url有人提到,其原因是IIS网站创建时没有hostheader。我尝试启动网站后添加了主机头。让我们找到解决方案

编辑2: 我试图启动网站后添加了主机名。这导致该网站有e空主机名,并在IIS中发生冲突。 (或者别的地方)。 我已更改我的脚本以获取网站,添加主机名,然后启动网站。 还增加了“的$RedgateWebsiteName"代替$RedGateWebSiteName.完美的作品现在

编辑3: 的测试运行后,我似乎结束了相同的错误的一个部署有没有问题,其他的部署,但这有

编辑4: 我已经更新脚本/错误/后 我删除了我的网站从IIS之后,我点击安装完美安装 - 没有问题,自动启动 第二轮完全相同,。第三次运行我得到上面的错误!

+0

你可以通过UI启动网站吗? –

+0

@DavidMartin是的,这是完美的作品。 – JochemQuery

回答

1

我在猜测$ RedGateWebSiteName变量没有被赋值,假设日志消息用它的值替换变量。从搜索结果来看,它看起来像IIS“文件已存在”消息可能是错误的,因为它发生的原因是缺少IP地址绑定到无效的虚拟目录文件夹。

+0

您是否尝试过检查系统的应用程序事件日志以查看是否存在网站未启动的有效原因? – Wonko

+0

我要查看事件日志,谢谢。 – JochemQuery

1

为什么你需要一个脚本来启动网站?如果您使用的是Red Gate部署管理器,它会在部署Web软件包(任何带有web.config文件的软件包)后启动网站。

它可能是为$ RedGateWebSiteName值取代不发生,它可能需要双引号:因为你的错误消息说,这

Start-Website "$RedGateWebSiteName"

我要说的是:

Start-Website <<<< $RedGateWebSiteName

而错误消息here显示替换值:

start-website <<<< "MyWebsite"

+0

谢谢你的回答,我试着在它周围放上“”,结果是开始网站<<<“$ RedGateWebsiteName”。我也试过让它出来,因为你说redgate会自己启动它。但这似乎并没有奏效。去挖掘一个日志文件,看看有什么不对。 – JochemQuery

0

我在网站启动时遇到了同样的问题:

Start-Website -Name MyWebSiteName 

并且它不会启动。当我试图手动在IIS管理器中启动它,它不会启动要么和我得到这个错误信息:

The World Wide Web Publishing Service (W3SVC) is stopped. Websites cannot be started unless the World Wide Web Publishing Service (W3SVC) is running. 

这是很明显,该服务没有启动,它被证明是真实的。