macos - Mac apache localhost 给出 403 Forbidden

标签 macos apache localhost virtualhost httpd.conf

我试图在我的新 mac OSX 10.9 上设置我的本地环境。我知道它已经安装了 apache,所以我一直在使用它。无论我如何设置 httpd-vhosts.conf/hosts/httpd.conf 文件,在浏览器上访问 localhost 或“test.com”时,我都会不断收到 403 禁止错误。下面列出了错误/文件/其他信息。

这是我在访问任一网页时遇到的错误

Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

我的/private/etc/hosts 文件
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

127.0.0.1       test.com
127.0.0.1       www.test.com

我的/private/etc/apache2/httpd.conf 文件
This file is in its original form besides the following changes:
Uncommented Include /private/etc/apache2/extra/httpd-vhosts.conf

我的/private/etc/apache2/extra/httpd-vhosts 文件
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Library/WebServer/Documents/
</VirtualHost>

<VirtualHost *:80>
        ServerName test.com
        ServerAlias www.test.com
        DocumentRoot "/Users/[my_name]/Sites/test"

        <Directory "/Users/[my_name]/Sites/test">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

其他注意事项
I've created a config file my user account in /private/etc/apache/users/
I've given that file read and write permissions to "everyone"
I've restarted apache after every save to any config file
I've reset the cache on my browser every time I make a change to these files
I have an index.html file set up in my /Users/[my_name]/Sites/test/ folder

使用命令 sudo apachectl -t 时
Warning: DocumentRoot [/usr/\xe2\x80\x9c/Users/joshwoelfel/Sites/test\xe2\x80\x9d] does not exist
httpd: Could not reliably determine the server's fully qualified domain name, using Joshs-MacBook-Air.local for ServerName
Syntax OK

我不知道此时该尝试什么。我花了几个小时查看教程和人们发布的其他问题。看起来我的文件和权限是正确的!

最佳答案

我刚刚解决了这个问题。尝试添加“要求所有人授予”而不是“所有人都允许”。

<VirtualHost *:80>
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot "/Users/[my_name]/Sites/test"

    <Directory "/Users/[my_name]/Sites/test">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Require all granted 
    </Directory>
</VirtualHost>

关于macos - Mac apache localhost 给出 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27134880/

相关文章:

macos - 任何支持 OS X 10.6.8 的快速代码编辑器

macos - 文件权限标志 @ 和 + 的用途是什么?

linux - 为什么 httpd 抛出 error_log 的权限被拒绝?

PHP - Fat Free Framework - 子文件夹中的命名 URL 路由 - 404

error-handling - 错误: listen EADDRINUSE: address already in use:::3000 … I got this error please tell me the solution this

objective-c - 如何在 Mac OSX 的 objective c 中获取和设置壁纸?

macos - NSTextField 具有像 Safari 地址栏一样的自动建议功能吗?

Apache Config - 从身份验证中排除位置

tomcat - 本地网络上的 Chromecast

javascript - 使用 ruby​​ 在 js 文件中使用来自 localhost 的 json 数据