我刚刚安装了全新的 Mac OS X Yosemite。我配置了 Apache 并将“users/user/Sites”修改为 755。当我点击 localhost 时,我收到 403 Forbidden“您无权访问此服务器上的/”
。我添加到主机文件中的任何其他网站都会发生同样的情况。
我尝试按照 this post 的帮助配置用户目录。伙计们MacRumors thread知道 Apache 存在问题,但没有提供很多建议。
我的目录权限如下所示
drwxr-xr-x 29 root wheel 1054 Aug 11 07:30 /
drwxr-xr-x 6 root admin 204 Aug 11 07:29 /Users/
drwxr-xr-x+ 26 zachshallbetter staff 884 Aug 11 11:57 /Users/zachshallbetter/
0: group:everyone deny delete
drwxr-xr-x 5 zachshallbetter staff 170 Aug 11 10:16 /Users/zachshallbetter/Sites
有人可以提供任何建议或帮助吗?以下是我的 hosts 的链接和 httpd.conf文件和error logs供引用。
最佳答案
您不想将整个硬盘驱动器开放给网络服务器进程。事实上,httpd.conf
的第 215-217 行说:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
对于 Directory directive in Module mod_authz_core,Apache 2.4 (OSX 10.10 Yosemite) 的结构与 Apache 2.2 (OSX 10.9) 不同。 .
编辑: 如果您从头开始设置 Apache,请按照 this instruction set 进行操作。在 OSX 10.10 Yosemite 上设置 apache 和 php。
假设您已经启用了 mod_userdir.so
,您的问题出在您的用户 .conf 文件 (/etc/apache2/users/username.conf
) 中,编辑 (或添加)以下内容。
Apache 2.2:
<Directory "/Users/jnovack/Sites/">
Options Indexes MultiViews
AllowOverride All
# OSX 10.9 / Apache 2.2
Order from deny, allow
</Directory>
Apache 2.4
<Directory "/Users/jnovack/Sites/">
Options Indexes MultiViews
AllowOverride All
# OSX 10.10 / Apache 2.4
Require all granted
</Directory>
关于macos - Yosemite 的 Apache localhost 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25250566/