我试图设置我的新的Mac OSX 10.9我的本地环境。 我知道它已经安装了Apache,所以我一直在使用它。 不pipe我如何设置我的httpd-vhosts.conf / hosts / httpd.conf文件,我在浏览器上访问本地主机或“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.
我的/私人/ 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
My / 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>
当您在Mac OS上设置DocuemntRoot“/ Users / xxx / xxx”时,您必须确保您的httpd用户&&组具有读取目录的权限。默认情况下,/ Users / xxx / xxx所有者为root,group为admin,没有权限。 如果你的目录组是轮子,也许工作。