快速回答是否定的。
'apachectl' 程序实际上只是一个 shell 脚本,所以(在意识到这一点之后)很容易看到它在做什么,以及为什么它没有按照我的预期做。
在 Mac 上重新启动 Apache(优雅地或以其他方式)时,相关的 launchctl 作业只是卸载并重新加载,我想这与Apache 对优雅重启的官方描述不同:
USR1 或优雅信号导致父进程建议子进程在当前请求后退出(或者如果他们没有提供任何服务则立即退出)
没有显示配置的虚拟服务器的原因apachectl -S
是因为该命令不是由launchctl运行的,因此没有加载/System/Library/LaunchDaemons/org.apache.httpd.plist中设置的环境变量。
因此,apachectl graceful
和apachectl restart
其他人确实加载了正确的变量,因此可以正确读取配置文件,但并非所有命令都默认执行。
为了克服这个问题,我手动编辑了 /usr/sbin/apachectl,如下所示。我所做的只是在适当的地方添加“-D MACOSXSERVER -D WEBSERVICE_ON”。
case $ARGV in
start)
run_launchctl load -w $LAUNCHD_JOB
ERROR=$?
;;
stop|graceful-stop)
run_launchctl unload -w $LAUNCHD_JOB
ERROR=$?
;;
restart|graceful)
run_launchctl unload -w $LAUNCHD_JOB 2> /dev/null
run_launchctl load -w $LAUNCHD_JOB
ERROR=$?
;;
startssl|sslstart|start-SSL)
echo The startssl option is no longer supported.
echo Please edit httpd.conf to include the SSL configuration settings
echo and then use "apachectl start".
ERROR=2
;;
configtest)
$HTTPD -t -D MACOSXSERVER -D WEBSERVICE_ON
ERROR=$?
;;
status|fullstatus)
echo Go to $STATUSURL in the web browser of your choice.
echo Note that mod_status must be enabled for this to work.
;;
*)
$HTTPD $ARGV -D MACOSXSERVER -D WEBSERVICE_ON
ERROR=$?
esac