【问题标题】:Apache Localhost 403 Forbidden with macOS Sierra [closed]macOS Sierra 禁止 Apache Localhost 403 [关闭]
【发布时间】:2017-01-30 13:51:38
【问题描述】:

macOS Sierra 更新使我的 Apache 的 localhost 现在无法访问。我只能访问localhost/。但localhost/<other-directory>/ 下的子文件夹不存在,并显示“403 禁止访问”错误。

【问题讨论】:

标签: apache macos-sierra


【解决方案1】:

这是我解决此问题所遵循的步骤:

转到 /private/etc/apache2 打开httpd.conf.bak,复制内容,覆盖httpd.conf,然后保存

在httpd.conf中,改变

Options FollowSymLinks Multiviews

到

Options FollowSymLinks Multiviews Indexes

改变

DocumentRoot "/Users/username/Sites"
<Directory "/Library/WebServer/Documents">

到

DocumentRoot "/Users/username/Sites"
<Directory "/Users/username/Sites">

然后保存

检查 /users/ 目录并转到您的 *.conf 文件并检查它是否类似于以下内容:

<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
# OSX 10.10 / Apache 2.4
Require all granted
</Directory> 

然后运行 ​​sudo apachectl restart

这应该可以工作:-)

【讨论】:

  • 还是不行,请帮帮我..不知道我卡在哪里了
  • 我也有同样的问题。我可以看到本地主机,但在我的目录 /Sites 中看不到我的 Web 文件。我按照你的回答做了,但没有用。
  • 这里有同样的问题......遵循所有可用的教程,但仍然没有骰子。它曾经在 Sierra 更新之前工作。
  • [终于成功了]检查这个apple.stackexchange.com/questions/95660/…
  • 像@Rohit 对我来说它仍然无法正常工作,但这是因为 /private/etc/apache2/extra/httpd-vhosts.conf 被一个仅包含演示站点的新文件替换,但是旧文件留在那里,名称为 httpd-vhosts.conf~previous
【解决方案2】:

请检查/private/etc/apache2/extra/httpd-userdir.conf文件。

改变

#Include /private/etc/apache2/users/*.conf

到

Include /private/etc/apache2/users/*.conf

然后重启 apache。

【讨论】:

  • 谢谢,该行在 Sierra 更新后被评论。我还发现,更新后,每个自定义文件最后都用 ~previous 重命名。在那里您可以找到您的自定义设置
  • 谢谢!我喜欢每次 OS X 更新都意味着新的 apache2 配置!!
  • 没有骰子:/ 对我没用
  • 解决方法无效。
猜你喜欢
  • 2018-08-14
  • 1970-01-01
  • 1970-01-01
  • 2014-07-06
  • 1970-01-01
  • 2016-12-03
  • 2011-10-21
  • 2014-09-20
相关资源
最近更新 更多