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

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

  $ apachectl fullstatus 

命令行上的响应是:

 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. 

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

 Syntax OK status_module (shared) 

这样做,我得到一个403说我没有访问服务器状态。 在查看访问日志,我看到:

 localhost - - [29/May/2012:17:36:53 +0800] "GET /server-status HTTP/1.1" 403 324 

错误日志:

 [Tue May 29 17:36:53 2012] [error] [client ::1] client denied by server configuration: /Library/WebServer/Documents/server-status 

我钻了/etc/apache/httpd.conf但找不到任何东西。

我如何configurationApache以便查看服务器状态?

为了使用mod_status处理对/server-status请求,你需要在你的configuration中的以下几行:

 <Location /server-status> SetHandler server-status </Location> 

不要忘记使用允许/拒绝或较新的Require指令限制对本地主机或其他可信主机的访问。

如果您正在运行Mac OS X 10.11 El Capitan,这是一个解决scheme。 注意:您需要pipe理员权限。 ( sudo

  • 在你的/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浏览器打开URL http://localhost/server-status ,并查看Apache的状态。

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