2014-01-10 70 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. 

這是很明顯,該服務沒有啓動,它被證明是真實的。