【问题标题】:Restarting apache web server from PowerShell script (log)从 PowerShell 脚本(日志)重新启动 apache Web 服务器
【发布时间】:2015-06-09 00:57:38
【问题描述】:

我有一个 powershell 脚本,可以在我的机器上重新启动 Apache Web 服务器。该脚本工作正常,但日志报告错误。错误似乎来自 Powershell,而不是 Apache,因为如果我只是做一个

.\httpd.exe -k config 

我没有错误,第一个喜欢

.\http.exe -k restart 

也不给出错误。 (注意: Powershell 在第 11 行抱怨,而不是在第 10 行第一次调用 httpd.exe)。我在 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.

【问题讨论】:

    标签: powershell powershell-4.0


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-02
    • 2012-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 2017-05-06
    相关资源
    最近更新 更多