如何访问 MacOS X Lion 上的服务器状态?

Ave*_*han 1 mac-osx apache-2.2

我正在运行 10.7.4。我已经启动并运行了 Apache。它按预期提供 html 和 php。我正在玩apachectl,想看看做了什么fullstatus。完整的命令是:

 $ apachectl fullstatus
Run Code Online (Sandbox Code Playgroud)

命令行上的响应是:

Go to http://localhost:80/server-status in the web browser of your choice.
Note that mod_status must be enabled for this to work.
Run Code Online (Sandbox Code Playgroud)

Aapachectl -t -D DUMP_MODULES | grep status显示:

Syntax OK
 status_module (shared)
Run Code Online (Sandbox Code Playgroud)

执行此操作后,我收到 403 消息,表示我无权访问服务器状态。在查看访问日志时,我看到:

localhost - - [29/May/2012:17:36:53 +0800] "GET /server-status HTTP/1.1" 403 324
Run Code Online (Sandbox Code Playgroud)

错误日志:

[Tue May 29 17:36:53 2012] [error] [client ::1] client denied by server configuration: /Library/WebServer/Documents/server-status
Run Code Online (Sandbox Code Playgroud)

我仔细研究了/etc/apache/httpd.conf但没有找到任何东西。

如何配置 Apache 以便查看服务器状态?

小智 5

如果您运行的是 Mac OS X 10.11 El Capitan,这就是解决方案。注意:您需要管理员权限。(须藤

  • 在你/etc/apache2/httpd.conf取消注释这些行
    • 第 153 行:LoadModule status_module libexec/apache2/mod_status.so
    • 第 497 行:Include /private/etc/apache2/extra/httpd-info.conf
  • 现在打开/etc/apache2/extra/httpd-info.conf第 14-18 行并将其更改为
    • <Location /server-status> SetHandler server-status Require host localhost </Location>

现在您可以使用 Web 浏览器打开 URLhttp://localhost/server-status并查看 apache 状态。

对于“fullstatus”,请将文本放置ExtendedStatus On/etc/apache2/extra/httpd-info.conf该行的正前方<Location /server-status>