请确保您正在更改正确的文件以适应您的安装。您可以像这样检查当前配置:
brew info httpd
以上内容应该给出已安装公式的路径,并且还应该显示文档根目录,例如在我的情况下:
httpd: stable 2.4.46 (bottled)
Apache HTTP server
https://httpd.apache.org/
/usr/local/Cellar/httpd/2.4.46_2 (1,657 files, 31.4MB) *
Poured from bottle on 2021-02-12 at 06:57:59
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/httpd.rb
License: Apache-2.0
==> Dependencies
Required: apr ✔, apr-util ✔, brotli ✔, nghttp2 ✔, openssl@1.1 ✔, pcre ✔
==> Caveats
DocumentRoot is /usr/local/var/www.
如果上述方法不起作用,您也可以使用 httpd 包中的
apachectl
命令获取 DocumentRoot:
cd `brew --prefix httpd`/bin
apachectl -D DUMP_RUN_CFG
这将会给你类似于下面的东西:
ServerRoot: "/usr/local/opt/httpd"
Main DocumentRoot: "/usr/local/var/www"
Main ErrorLog: "/usr/local/var/log/httpd/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/httpd/httpd.pid"
Define: DUMP_RUN_CFG
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used
您可以使用以下命令显示当前的虚拟主机配置:
apachectl -D DUMP_VHOSTS