gpt4 book ai didi

macos - Mac apache localhost 给出 403 Forbidden

转载 作者:行者123 更新时间:2023-12-04 17:18:46 24 4
gpt4 key购买 nike

我试图在我的新 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com