0

我在我的有这个配置httpd-vhosts.conf

<Directory "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>
<Virtualhost *:80>
    VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/_localhost"
    UseCanonicalName Off
</Virtualhost>
<Virtualhost *:80>
   VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/%2"
   ServerName sites.dev
   ServerAlias www.*.dev
   ServerAlias www.*.dev.*.xip.io
   UseCanonicalName Off
</Virtualhost>
<Virtualhost *:80>
    VirtualDocumentRoot "/Users/uername/Library/Mobile Documents/com~apple~CloudDocs/Sites/%1"
    ServerName sites.dev
    ServerAlias *.dev
    ServerAlias *.dev.*.xip.io
    UseCanonicalName Off
</Virtualhost>

当我尝试访问我的网站时,我得到一个 403 禁止页面。当我查看 apache 错误日志时,我看到:

[Sun Jun 26 12:09:12.310868 2016] [core:error] [pid 1272] (13)Permission denied: [client 127.0.0.1:50110] AH00035: access to /favicon.ico denied (filesystem path '/Users/username/Library/Mobile Documents') because search permissions are missing on a component of the path, referer: http://site.dev/

我不完全理解为什么路径会停在Mobile Documents. 所有文件夹都存在,我的index.php根目录中确实有一个文件,没有其他任何东西可以解释 403 错误。

我在这里想念什么?我怎么解决这个问题?

4

1 回答 1

1

啊,我解决了这个问题。可能不是最好的方法,但它有效,所以如果有人有更好的想法,请分享。我的解决方案:我将 apache 从 _www 运行的用户和组更改为我自己的用户名和组。我使用了这个解决方案: https ://coolestguidesontheplanet.com/forbidden-403-you-dont-have-permission-to-access-username-on-this-server/

更改 Apache Web 用户

使用 Users/username/Sites 文件夹的挫折之一是更新和身份验证等权限问题。

这是因为运行的默认网络服务器用户httpd称为_www,它不是您本地帐户中的用户。如果您的机器仅供您使用,并且网络服务器将仅在您的帐户下运行,那么您可以更改用户。

改回这个/etc/apache2/httpd.conf

osx-yosemite-webserveruser

只需将其更改为您的用户名和组,组将是人员并重新启动 Apache

sudo apachectl restart

于 2016-06-26T10:44:11.143 回答