Apache尝试访问"/"时给我403错误.在服务器上 [英] Apache Gives me 403 Error when trying to access "/" on server

查看:88
本文介绍了Apache尝试访问"/"时给我403错误.在服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将Web根目录路径更改为任何其他文件夹时,它给我一个403错误(禁止访问),默认路径为/Library/WebServer/Documents ,但是因为这样做很烦人我,我也更改了它/Users/Xero/WebServer

When I try to change the web root path to any other folder it give me a 403 error (Forbidden), The default path is /Library/WebServer/Documents, but since this rather annoying for me, I changed it too /Users/Xero/WebServer

权限

通过右键单击并选择 Get info (

Permissions

I got the permissions from /Library/WebServer/Documents by right clicking and selecting Get info (http://i.imgur.com/f21D7z0.png What it looks like)

因此,我将其更改为与/Users/Xero/WebServer 完全相同.但这仍然给我一个403错误.

So I changed it to be the exact same for /Users/Xero/WebServer. But it give me a 403 error still.


因此,我在Google上进行了查找,并尝试了以下解决方案来解决我的问题:

So, I looked it up on Google, and I tried these solutions to fix my problem:

http://www.cyberciti.biz/常见问题解答/apache-403-forbidden-error-and-solution/

>错误消息禁止访问"您无权访问此服务器上的/"" (堆栈溢出)

但是他们没有帮助.



其他说明

记住,我在OS X Snow Leopard上使用的是预安装的Apache.而且,我的虚拟主机不是本地主机,因此也不是主机的一部分,也不是 hosts 文件的问题(它是由DNS托管的,而IP作为备份托管的,两者都不起作用)



Other Notes

Remember I'm using the preinstalled Apache on OS X Snow leopard. And, my virtual host isn't local, so it's not part or the hosts file issue (It's hosted off my DNS, and my IP as a backup, neither work)

我的虚拟主机:

<VirtualHost *:80>                                      ( Edited 2 )
    DocumentRoot "/Users/Xero/WebServer" 
</VirtualHost>

<VirtualHost *:80>
        Options Indexes FollowSymLinks Includes ExecCGI
        DocumentRoot "/Users/Xero/WebServer"
        ServerName wrks.tk
        ErrorLog "/Logs/Workarea/wrks-err"
        CustomLog "/Logs/Workarea/wrks-acc" common
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
        <Directory "/Users/Xero/WebServer">
                Options +Indexes FollowSymLinks +ExecCGI
                AllowOverride AuthConfig FileInfo
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot "/Users/Xero/WebServer"
        ServerName 209.169.203.53
        ErrorLog "/Logs/Workarea/ip"
        CustomLog "/Logs/Workarea/ip-acc" common
        <Directory "/Users/Xero/WebServer">
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

此外,我的httpd.conf User Group 设置如下:

Also, I have my httpd.conf User and Group setup like this:

User _www
Group _www



  1. 因此,我将路径固定为文档的路径,但是它仍然给我相同的错误403.
  2. 我检查了我的FireWall设置,然后将其关闭.我还检查了共享首选项",文件共享"和网络共享"是否处于打开状态.
  3. 我在"wrks.tk" VirtualHost中编辑了"DirectoryIndex Home.php Home.html"的副本,但是仍然遇到相同的错误.(请参阅其他说明)
  4. 添加了更多其他注释.
  5. 固定目录,但仍不能解决问题.
  6. 在答复"中添加了另一个.
  7. 尝试重新启动计算机,无法正常工作.
  8. 我在文件夹中放置了一个`index.html`,仍然出现相同的403错误,我仍然尝试访问`/index.html`,仍然是403.

推荐答案

您究竟从哪个文件中获得了所有这些信息?

What file exactly are you getting all of this from?

<VirtualHost *:80>                                      ( Edited 2 )
DocumentRoot "/Users/Xero/WebServer" 
</VirtualHost>

<VirtualHost *:80>
    Options Indexes FollowSymLinks Includes ExecCGI
    DocumentRoot "/Users/Xero/WebServer"
    ServerName wrks.tk
    ErrorLog "/Logs/Workarea/wrks-err"
    CustomLog "/Logs/Workarea/wrks-acc" common
    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
    <Directory "/Users/Xero/WebServer">
            Options +Indexes FollowSymLinks +ExecCGI
            AllowOverride AuthConfig FileInfo
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/Xero/WebServer"
    ServerName 209.169.203.53
    ErrorLog "/Logs/Workarea/ip"
    CustomLog "/Logs/Workarea/ip-acc" common
    <Directory "/Users/Xero/WebServer">
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

这些设置有多个文件.如果您使用的是Apache,则请查看 sites-enabled sites-available 文件夹.

There are more than one file for those settings. If you have apache, then take a look in the sites-enabled and sites-available folders.

httpd.conf 文件的底部更改为:

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted


制作一个新文件 index.html 并将以下内容放入其中:


Make a new file index.html and put the following in it:

<!DOCTYPE html>
<html>
<body>

<h1>It works!</h1>

<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>

</body>
</html>

然后将 index.html 文件放入空目录.

Then place the index.html file into the empty directory.

/etc/apache2/users/中创建一个名为 yourusername.conf 的文件(您的用户名是帐户的简称,例如hulu –通常是您家的名称/Users中的文件夹),其中包含以下内容:

create a file in /etc/apache2/users/ called yourusername.conf (yourusername being the account short name, e.g. hulu – it's usually the name of your home folder in /Users) with the following contents:

<Directory "/Users/yourusername/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

这篇关于Apache尝试访问"/"时给我403错误.在服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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