我有一个powershell脚本,可以在我的机器上重启Apache Web服务器。该脚本工作正常,但日志报告错误。错误似乎来自Powershell,而不是Apache,因为如果我只是做了
.\httpd.exe -k config
我没有错误,第一个喜欢
.\http.exe -k restart
也没有出错。 (注意: Powershell在第11行抱怨,而不是第一次调用httpd.exe#10)。我在Windows 7上使用的是PowerShell V4。
所以我想了解Powershell在这里做了什么,因为我认为Apache工作正常。
这是脚本:
# This PowerShell script restarts apache
start-transcript -Path install.log -Append
Write-Host "apache.ps1 Script`r`n"
$sixtyfour = [Environment]::Is64BitProcess
$exe = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe"
Write-Host "64-Bit Powershell: "$sixtyfour
& $exe -k restart *>> install.log
Write-Host ""
& $exe -k config *>> install.log
这是日志:
httpd.exe : Reconfiguring the Apache2.2 service
At G:\wwwroot\setup\apache.ps1:11 char:1
+ & $exe -k config *>> install.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Reconfiguring the Apache2.2 service:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
答案 0 :(得分:0)