Mac 上 apchectl status 默认检查 8080 端口

在 Mac 上 $ brew install httpd 之后的 Apache 默认侦听在 8080 端口。

# apachectl -S
VirtualHost configuration:

ServerRoot: “/usr/local/opt/httpd”
Main DocumentRoot: “/usr/local/var/www”
Main ErrorLog: “/usr/local/var/log/httpd/error_log”
Mutex default: dir=”/usr/local/var/run/httpd/” mechanism=default
Mutex mpm-accept: using_defaults
Mutex rewrite-map: using_defaults
PidFile: “/usr/local/var/run/httpd/httpd.pid”
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name=”_www” id=70
Group: name=”_www” id=70

其实没有 # httpd -V 这样的命令直观的显示,可以展示Apache 启动目录,配置的文件的路径等。
当我们设置了虚拟主机,修改了侦听端口,网站能正常起来后, 用 apchectl status ,首先是报告 lynx 没有安装。
当然, 这个很简单,  brew install lynx 即可解决。
但是安装 lynx 后还是报告 8080 端口的 Apache 没有起来。
我们需要修改 /usr/local/bin/apachectl ,把路径里的 8080 去掉。

STATUSURL=”http://localhost:8080/server-status”

然后还要去 /usr/local/etc/httpd/httpd.conf 添加:

<Location /server-status>
SetHandler server-status

Order Deny,Allow
Deny from all
Allow from localhost
</Location>

用 root 重启 apache 后,运行 # apachectl status 就正常了:

Apache Server Status for localhost (via ::1)

Server Version: Apache/2.4.29 (Unix) PHP/5.6.33
Server MPM: prefork
Server Built: Dec 28 2017 00:52:51
__________________________________________________________________

Current Time: Monday, 26-Feb-2018 11:56:43 CST
Restart Time: Monday, 26-Feb-2018 11:56:13 CST
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 30 seconds
Server load: 3.30 3.08 2.57
Total accesses: 2 – Total Traffic: 5 kB
CPU Usage: u0 s0 cu0 cs0
.0667 requests/sec – 170 B/second – 2560 B/request
1 requests currently being processed, 4 idle workers

_W___…………………………………………………..
……………………………………………………….
……………………………………………………….
……………………………………………………….

Scoreboard Key:
“_” Waiting for Connection, “S” Starting up, “R” Reading Request,
“W” Sending Reply, “K” Keepalive (read), “D” DNS Lookup,
“C” Closing connection, “L” Logging, “G” Gracefully finishing,
“I” Idle cleanup of worker, “.” Open slot with no current process

当然, 直接浏览器访问也是一样的结果:  http://localhost/server-status

作者: 甬洁网络

--移动互联网&物联网技术提供商