Mac apache localhost给403禁止 [英] Mac apache localhost giving 403 Forbidden

查看:668
本文介绍了Mac apache localhost给403禁止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Im trying to set up my local environment on my new mac OSX 10.9. I know it has apache already installed, so i've been using that. No matter how I set up my httpd-vhosts.conf/hosts/httpd.conf files, I continuously get a 403 forbidden error when visiting localhost OR "test.com" on my browser. The error / files / other information is listed below.

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

This is the error I'm getting when visiting either web page

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文件

My /private/etc/hosts file

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文件

My /private/etc/apache2/httpd.conf file

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文件

My /private/etc/apache2/extra/httpd-vhosts file

<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

When using the command 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

我现在不知道该怎么办.我花了几个小时查看教程和其他人发布的问题.看来我的文件和权限正确!

I don't know what to try at this point. I've spent several hours looking at tutorials and other questions people have posted. It looks like my files and permissions are correct!

推荐答案

我刚刚解决了此问题.尝试添加要求所有被授予的权限",而不是全部允许".

I just resolved this issue. Try adding 'Require all granted' instead of 'Allow from all'.

<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>

这篇关于Mac apache localhost给403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆