apache - 403 禁止 : Apache not working after moving document root folder to iCloud drive

标签 apache icloud macos-catalina icloud-drive

所以我使用的是 MacOS Catalina,我的 Apache 环境运行良好,直到我决定将我的文档根目录移动到 iCloud 驱动器,以对其进行备份。

在我的文档根目录之前是:

/users/admin/www

现在是

/users/admin/Library/Mobile Documents/com~apple~CloudDocs/www

我相应地编辑了 httpd.conf :

DocumentRoot "/users/admin/Library/Mobile Documents/com~apple~CloudDocs/www"
<Directory "/users/admin/Library/Mobile Documents/com~apple~CloudDocs/www">
    Options FollowSymLinks Multiviews SymLinksIfOwnerMatch
    MultiviewsMatch Any
    AllowOverride All
    Require all granted
</Directory>

<Directory "/users/admin/Library/Mobile Documents/com~apple~CloudDocs/www/myfolder">
    Options +FollowSymLinks +Multiviews +SymLinksIfOwnerMatch
    MultiviewsMatch Any
    AllowOverride All
    Allow from All
    Require all granted
</Directory>

重新启动 Apache,重新启动机器,但现在我可以访问 127.0.0.1,除了一个特定的文件夹(我们称它为 www/myfolder)。当我尝试访问 127.0.0.1/myfolder 时,出现以下错误:

Forbidden
You don't have permission to access / on this server.

检查 apache 日志文件,这是我得到的错误:

[Thu Oct 24 14:00:24.830700 2019] [access_compat:error] [pid 61703] [client 127.0.0.1:57804] AH01797: client denied by server configuration: /users/admin/Library/Mobile Documents/com~apple~CloudDocs/www/myfolder/public_html/

我在这里错过了什么?请帮忙,我需要工作 :D

最佳答案

我首先看到的是您在目录 block 中使用的是 Apache 2.4 样式语法,但是在您的错误日志中,抛出错误的模块是 access_compat。根据 Apache 文档:

The directives provided by mod_access_compat have been deprecated by mod_authz_host. Mixing old directives like Order, Allow or Deny with new ones like Require is technically possible but discouraged. This module was created to support configurations containing only old directives to facilitate the 2.4 upgrade

下一条线索是错误代码:AH01797。这是由 server configuration issue 引起的:

Client denied by server configuration

This error means that the access to the directory on the file system was denied by an Apache configuration.

我在这里假设您实际上使用的是 2.4,并且错误地启用了 access_compat

再次查看您的配置文件,找到正在加载 mod_access_compatLoadModule 指令,并将其注释掉。它可能在您的 httpd.conf 文件中,但是组织和配置 Apache 安装的方式多种多样,因此它可能在其他地方。如果您有 Debian 风格的安装,则需要删除符号链接(symbolic link) /etc/apache2/mods_enabled/mod_access_compatGrep -R access_compat * 可能有帮助。

编辑另外 2 个观察结果:

  1. 在第二个目录节中,你有
Allow from all
Require all granted

这是将旧指令语法与新指令语法混合在一起,也是多余的。再次禁用 access_compat,并在重新启动 Apache 之前删除 Allow from all 行。

  1. 我认为第二个 directory 节甚至没有必要。您可能可以删除整个 block 并重新启动服务器,这样就可以了。

首先尝试 (1) 通过禁用 access_compat 并从 httpd.conf 文件中删除 Allow 指令,然后使用 重新启动 apache >apache2ctl -k 优雅。如果这不起作用,请注释掉整个第二个 directory 节并重新启动。

我大约有 50% 的把握可以解决这个问题。如果没有,那么我真的需要查看您的整个 httpd.conf 文件,然后才能进一步排除故障。

关于apache - 403 禁止 : Apache not working after moving document root folder to iCloud drive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58321852/

相关文章:

swift4 - 如何修复“读写数据沙盒 : error when using Mac Catalyst”

c - 当工作区位于 ~/src 而不是/tmp 时,VS Code 在 "stdio.h"下显示红色曲线

apache - 如何使网络上的其他人可以访问我的本地网络服务器?

html - 我怎样才能找到我的工作目录?

ios - 来自存储在 iCloud 上的图像的 CGImage 看起来不对

export - 备份/恢复 Notes.app 中的笔记,即存储在 iCloud 中(iOS、Mac OS X Mountain Lion)

python - 在 Django 和 Apache 中使用 WSGI 时如何修复 "Timeout when reading response headers from daemon process"错误

javascript - 启用js重定向到apache服务器的私有(private)文件夹

ios - 一部手机上有 2 个相同的应用程序?

macos - 通过更改 .zshrc 删除 zsh 中的主机名