Apache2虚拟主机不能在macOS上工作



尝试使用Homebrew在macOS Big Sur上设置apache2虚拟主机。当我在浏览器中转到127.0.0.1时,它得到了正确的网站(一个基本的HTML文件),但是当我试图访问服务器名称http://ms-dashboard.harry.milestone.barn/时,它说网站无法到达。

httpd.conf中的重要内容

Listen 80
ServerName harry.milestone.barn
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf

httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "/Users/harry/Sites/MS-Dashboard/public"
ServerName ms-dashboard.harry.milestone.barn
ErrorLog "/Users/harry/Sites/MS-Dashboard/logs/error_log"
CustomLog "/Users/harry/Sites/MS-Dashboard/logs/access_log" common
</VirtualHost>

主机

127.0.0.1       localhost harry.milestone.barn ms-dashboard.harry.milestone.barn
255.255.255.255 broadcasthost
::1             localhost

访问127.0.0.1时的错误日志

[Wed Jun 01 10:25:39.133465 2022] [authz_core:debug] [pid 1219] mod_authz_core.c(815): [client 127.0.0.1:63629] AH01626: authorization result of Require all granted: granted
[Wed Jun 01 10:25:39.133898 2022] [authz_core:debug] [pid 1219] mod_authz_core.c(815): [client 127.0.0.1:63629] AH01626: authorization result of <RequireAny>: granted
[Wed Jun 01 10:25:59.133782 2022] [reqtimeout:info] [pid 1220] [client 127.0.0.1:63630] AH01382: Request header read timeout

访问日志

127.0.0.1 - - [01/Jun/2022:10:25:39 +0100] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [01/Jun/2022:10:25:59 +0100] "-" 408 -

当ms-dashboard.harry.milestone.barn被访问时,日志不会被改变。

关于同一件事,我看了一百万个不同的StackOverflow问题,他们的解决方案都不起作用。

解决:有两个主机文件,我编辑错了

最新更新