我浏览了所有我能找到的在 Big Sur 上安装和配置 Apache 的教程。教程在讨论配置文件时总是会指向 /usr/local/etc/httpd/httpd.conf ,需要稍微修改一下。唯一的问题是当我检查该目录时该文件不存在。任何想法?感谢您提前的帮助。
编辑:我按照请求卸载并安装了 httpd,但我仍然没有得到 /usr/local/。自制配置一定有不同。
➜ ~ brew uninstall httpd Uninstalling /opt/homebrew/Cellar/httpd/2.4.49... (1,660 files, 31.9MB) ➜ ~ brew install httpd ==> Downloading https://ghcr.io/v2/homebrew/core/httpd/manifests/2.4.49 Already downloaded: /Users/johnny/Library/Caches/Homebrew/downloads/6c60d66c3915be5c993e144a743960b9e6be26e557efeeb6c61f530c79ffed34--httpd-2.4.49.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/httpd/blobs/sha256:e6ebcb4a1307 Already downloaded: /Users/johnny/Library/Caches/Homebrew/downloads/8506f199d5d7def536481d6fa87aa94c25201b57072d032e97edb8ce78fa86a3--httpd--2.4.49.arm64_big_sur.bottle.tar.gz ==> Pouring httpd--2.4.49.arm64_big_sur.bottle.tar.gz ==> Caveats DocumentRoot is /opt/homebrew/var/www. The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo. To restart httpd after an upgrade: brew services restart httpd Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND ==> Summary 🍺 /opt/homebrew/Cellar/httpd/2.4.49: 1,660 files, 31.9MB ➜ ~
[编辑和更新] 我使用的是 macOS Catalina 10.15.7 / Xcode-select 版本 2373,通过运行
$ brew install httpd
我可以在 /usr/local/
下安装 Apache 服务
您可以使用相同的命令并共享所有输出来重新删除并安装它吗?
这些是重要的事情:
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To start httpd:
brew services start httpd
Or, if you don't want/need a background service you can just run:
/usr/local/opt/httpd/bin/httpd -D FOREGROUND
这是目录列表。
$ ls -lrt /usr/local/etc/httpd
total 200
drwxr-xr-x 14 user admin 448 Sep 22 23:35 extra
-rw-r--r-- 1 user admin 21222 Sep 22 23:35 httpd.conf
-rw-r--r-- 1 user admin 13064 Sep 22 23:35 magic
-rw-r--r-- 1 user admin 60847 Sep 22 23:35 mime.types
drwxr-xr-x 4 user admin 128 Sep 22 23:35 original
这是我的测试,表明它有效。
$ curl localhost:8080
<html><body><h1>It works!</h1></body></html>
$ tail -f /usr/local//var/log/httpd/access_log
::1 - - [22/Sep/2021:23:39:35 -0500] "GET / HTTP/1.1" 200 45
根据您的输出和brew文档,我相信您正在使用
Apple Silicon
是正确的,您能确认吗?
https://docs.brew.sh/Installation
Brew 窃取了@JohnDifool 上面的评论,时不时地移动 httpd.conf 文件。我确信他们有充分的理由。上述内容对于 OS X Big Sur 来说是正确的,但情况确实发生了变化。我来到这里寻找 Ventura 13.4 下的当前位置,其他用户也可能会遇到此页面。然而,正如约翰指出的那样,终端中的查找功能是您的朋友。
find /opt -name httpd.conf
me@mymac ~ % find /opt -name httpd.conf
/opt/homebrew/etc/httpd/httpd.conf
/opt/homebrew/etc/httpd/original/httpd.conf
/opt/homebrew/Cellar/httpd/2.4.54_1/.bottle/etc/httpd/httpd.conf
/opt/homebrew/Cellar/httpd/2.4.54_1/.bottle/etc/httpd/original/httpd.conf
然后路径就会出现。此时(7/28/23)在 Mac OS X Ventura 13.4 下,文件 httpd.conf 位于 /opt/homebrew/etc/httpd/
如果服务器正在运行,您还有一个附加选项。 http 守护进程可以告诉你。如果您的系统上有多个 httpd.conf 文件(例如一个来自brew,另一个来自Apple 默认文件),这会非常方便。
httpd -t -D DUMP_INCLUDES