AH00035:访问/被拒绝(文件系统路径“/Users/xxx/Documents/workspace”),因为路径的某个组件缺少搜索权限

hor*_*ars 5 apache permissions localhost httpd.conf

尝试在我的 mac 上设置 localhost 并在 /etc/apache2/httpd.conf 中进行以下更改

DocumentRoot "/Users/xxx/Documents/workspace/firstRepo/htdocs"
<Directory "/Users/xxx/Documents/workspace/firstRepo/htdocs">
Run Code Online (Sandbox Code Playgroud)

我知道这与 dir 权限有关,因此我按照在线建议并运行以下命令:

find /Users/xxx/Documents/workspace -type d -exec chmod 755 {} \;
find /Users/xxx/Documents/workspace -type f -exec chmod 644 {} \;
Run Code Online (Sandbox Code Playgroud)

这里没有运气。有人可以帮我弄这个吗?谢谢。

ezr*_*a-s 9

Unix 权限不仅仅是“目标权限”,您需要“搜索”整个路径的权限,直到最后一个目录,如来自 Apache 的消息所述

搜索权限意味着,在一个简单的解释中,“x”至少在目录中丢失,因此非特权用户 apache 使用可以走整个路径,直到到达“/Users/xxx/Documents/workspace/firstRepo/htdocs”。

您可以尝试使用此命令以确保您拥有它们:

namei -mol /Users/xxx/Documents/workspace/firstRepo/htdocs
Run Code Online (Sandbox Code Playgroud)

只有其他无法访问权限正确的情况是 SELinux 控制对这些目录的访问。

Apache wiki 有一个关于此的文档,因为许多人对 Unix 下的权限如何工作感到困惑。权限

  • 谢谢。在 mac 操作系统中找不到 namei 命令。但我发现问题是因为 /Users/xxx 文件夹只有所有者的权限。我通过 `chmod +x /Users/xxx` 修复了它 (3认同)
  • SELinux 是我的案例中的问题,将其从强制改为宽松,并且有效。`sudo setenforce 0` (2认同)