最近我在运行 MacOs Ventura 的机器上使用 brew 安装了 Apache / PHP。它运行了几天,直到我不得不重新启动机器。
现在,当我尝试导航到本地主机时,我收到 403 Forbidden 并且 Apache 错误日志显示很多这样的行:
[Wed Aug 02 10:10:06.198965 2023] [core:error] [pid 337] (13)Permission denied: [client ::1:51255] AH00035: access to /favicon.ico denied (filesystem path '/Users/admin/Library') because search permissions are missing on a component of the path, referer: http://localhost/
以下是我已经尝试过但没有运气的事情:
1 - 使用brew services restart httpd 重新启动Apache
2 - 检查我的 www 文件夹权限,每个人都可以“读取和写入”。
3 - 尝试在 MacOs 上将我的 www 文件夹标记为“共享文件夹”
3 - 检查了我的 www 文件夹的 httpd.conf 设置,如下所示:
DocumentRoot "/Users/admin/Library/Mobile Documents/com~apple~CloudDocs/www"
<Directory "/Users/admin/Library/Mobile Documents/com~apple~CloudDocs/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
我还应该寻找什么?
在解决这个问题几天后,我发现我需要的只是使用 sudo 启动 httpd :
sudo brew services restart httpd
我的猜测是,因为我的www文件夹位于我的icloud文件夹中,所以它需要管理员权限。