如何在MacOS-Mojave上使用Homebrew Apache找到文档根目录?

4

Mac OS X Mojave

我在遵循https://www.dionysopoulos.me/custom-apache-and-php-server-on-macos-the-definitive-2019-edition/的指示,已经到达了“安装MySQL”之前的步骤。

本地主机与Apache默认文件配合正常,显示 "It Works!"。

我尝试更改index.html文件,在“ It ”之前添加星号。 但仍然是默认页面。

我尝试了http://localhost/?2以强制清除缓存,但仍然是默认页面。

我将httpd.conf更改回原始位置 /usr/local/var/www,并将修改后的index.html文件放置在那里。 但仍然失败。

我还尝试更改/usr/local/Cellar/httpd/2.4.41_1/.bottle/var/www/index.html,但仍然是默认页面。

如何找出Apache实际提供服务的位置?

1个回答

1

请确保您正在更改正确的文件以适应您的安装。您可以像这样检查当前配置:

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接