Macos Mac apache本地主机提供403禁止
我正在尝试在我的新mac OSX 10.9上设置本地环境。我知道它已经安装了apache,所以我一直在使用它。无论我如何设置httpd-vhosts.conf/hosts/httpd.conf文件,在访问浏览器上的localhost或“test.com”时,我都会不断收到403禁止的错误。下面列出了错误/文件/其他信息Macos Mac apache本地主机提供403禁止,macos,apache,localhost,virtualhost,httpd.conf,Macos,Apache,Localhost,Virtualhost,Httpd.conf,我正在尝试在我的新mac OSX 10.9上设置本地环境。我知道它已经安装了apache,所以我一直在使用它。无论我如何设置httpd-vhosts.conf/hosts/httpd.conf文件,在访问浏览器上的localhost或“test.com”时,我都会不断收到403禁止的错误。下面列出了错误/文件/其他信息 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1
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
这是我在访问任一网页时遇到的错误
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.
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/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
My/private/etc/apache2/httpd.conf文件
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
This file is in its original form besides the following changes:
Uncommented Include /private/etc/apache2/extra/httpd-vhosts.conf
My/private/etc/apache2/extra/httpd vhosts文件
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
<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>
使用命令sudo apachectl-t时
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
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
我不知道在这一点上该尝试什么。我花了好几个小时看教程和人们发布的其他问题。看起来我的文件和权限是正确的 我刚刚解决了这个问题。尝试添加“要求全部授予”而不是“允许全部”
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
<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>
ServerName test.com
ServerAlias www.test.com
DocumentRoot“/Users/[my_name]/Sites/test”
选项索引如下SYMLINKS包括ExecCGI
允许超越所有
要求所有授权
在mac os上设置DocuemntRoot“/Users/xxx/xxx”时,必须确保您的httpd用户和组具有读取目录的权限。默认情况下,/Users/xxx/xxx所有者为root,组为admin,因此您没有该权限。如果您的目录组正常,它可能会工作。上次升级到MacOS HighSierra 10.13.4后,我收到了相同的消息。我尝试过不同的解决方案,但真正让我感到惊讶的是一篇文章提到,当你收到这条消息时,通常只是权限问题。因此,最后我只需要确保将组和文档根的所有者(我不将其保留在我的概要文件路径下)以及子目录(由httpd.conf中指定的同一用户和组拥有)设置为我的组和用户名。httpd.conf中的默认值分别为:_www和wheel。如果您不确定您的用户名,请使用
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
whoami
在终端窗口上
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
如果您有兴趣将文件保存在个人资料目录下。谢谢!还有很多其他教程没有将
权限放在
中。将权限设置放在/etc/apache2/users/myusername.conf
中对我不起作用。在/etc/apache2/extra/httpd vhosts.conf
中添加目录权限有效!
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