33

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

4

2 回答 2

30

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

转到 /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

那应该可以工作:-)

于 2016-09-23T09:21:25.463 回答
27

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

改变

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

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

并重新启动apache。

于 2016-10-14T11:35:57.697 回答