403紫禁城,中/捕获22指数 [英] 403 Forbidden, Index of / catch 22

查看:252
本文介绍了403紫禁城,中/捕获22指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常粗略的时间就这一个,并试图一吨已工作了某些人,但不适合我的解决方案。首先我的设置: Ubuntu的14.04.2 阿帕奇2.4.7

I'm having a really rough time on this one and have tried a ton of solutions which have worked for certain people but not for me. Firstly my set up: Ubuntu 14.04.2 Apache 2.4.7

我目前正在迁移我的网站,以字preSS到文件夹结构的/ var / WWW的/ dev被设置为一个虚拟主机 - dev.conf是这样的:

I'm currently migrating my site to wordpress into the folder structure /var/www/dev which is set up as a virtual host - dev.conf looks like:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    ServerAdmin ubuntu@12.345.678.90
    DocumentRoot /var/www/dev
    ServerName dev.mysite.com

    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/dev/>
            Options -Indexes +FollowSymLinks
            AllowOverride All
            #Require all granted
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

我的问题是,当我进入我的主页在浏览器中首次dev.mysite.com它引导我到一个403页面:

My problem is that when I access my home page in a browser for the first time dev.mysite.com it directs me to a 403 page:

Forbidden 
You don't have permission to access / on this server.

我也有我的根文件夹中的.htaccess文件,看起来像这样目前:

I also have an .htaccess file in my root folder that looks like this currently:

DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我跟着2套不同意见,到目前为止 - 一个说给我的配置选项更改为:

I followed 2 different sets of advice so far - one saying to change my config Option to:

Options +Indexes

然而,当我浏览到我的主页它给我的物理文件夹中/索引我所有的文件和文件夹列表 - 我不想要的。所以,我已经离开了它作为

However when i navigate to my home page it gives me the physical folder "Index of /" with a list of all my files and folders - which I don't want. So I've left it as

Options -Indexes

另一组建议说,这添加到htaccess文件:

Another set of advice said add this to the htaccess file:

DirectoryIndex index.php index.html

我也检查了我的文件夹的权限,通过我的apache用户管理所有的Ubuntu拥有:Ubuntu和所有遵循标准的文字preSS文件夹的权限,例如所有文件夹都是755的所有文件都是644(拇指粗规则)。

I've also checked my folder permissions, all owned by my apache user admin ubuntu:ubuntu and all follow the standard wordpress folder permissions e.g. all folders are 755 all files are 644 (rough rule of thumb).

我还使用了新的Apache试过,你可以看到(上面注释)2.4标准

I've also tried as you can see (commented out above) using the new apache 2.4 standard

Require all granted 

而不是

I'm also restarting the server every time I make a change so nothing silly like that. What am I doing in the above config that's not letting me load my site?

我也每次我做出改变所以没有什么愚蠢的那样重新启动服务器。那我在上面的配置,这不是让我载入我的网站做什么?

Specifically my homepage goes to 403 Forbidden, any other page e.g. dev.mysite.com/features loads this error message:

具体我的主页去403禁止,任何其他页面如dev.mysite.com/features~~V加载此错误消息:

User-agent: * Disallow: /wp-admin/

EDIT:
The above issues only occur when the url is loaded initially - if I refresh the page it loads as it should.

编辑: 当URL被装载最初的上述问题才会发生 - 如果我刷新页面加载,因为它应该

Here's my file ownership structure - perhaps this may provide useful:

下面是我的文件的所有权结构 - 这也许可以提供有用的:

-rw-rw-r-- 1 ubuntu ubuntu 350 Sep 26 19:35 .htaccess -rw-rw-r-- 1 ubuntu ubuntu 4951 Sep 9 13:21 wp-activate.php drwxrwxr-x 9 ubuntu ubuntu 4096 Sep 9 13:21 wp-admin -rw-rw-r-- 1 ubuntu ubuntu 271 Sep 9 13:21 wp-blog-header.php -rw-rw-r-- 1 ubuntu ubuntu 5007 Sep 9 13:21 wp-comments-post.php -rw-rw-r-- 1 ubuntu ubuntu 3130 Sep 24 10:32 wp-config.php -rw-rw-r-- 1 ubuntu ubuntu 2764 Sep 16 17:23 wp-config-sample.php drwxrwxr-x 6 ubuntu ubuntu 4096 Sep 24 10:46 wp-content -rw-rw-r-- 1 ubuntu ubuntu 3286 Sep 16 17:23 wp-cron.php drwxrwxr-x 12 ubuntu ubuntu 4096 Sep 9 13:21 wp-includes -rw-rw-r-- 1 ubuntu ubuntu 2380 Sep 9 13:21 wp-links-opml.php -rw-rw-r-- 1 ubuntu ubuntu 3123 Sep 9 13:21 wp-load.php -rw-rw-r-- 1 ubuntu ubuntu 34669 Sep 16 17:23 wp-login.php -rw-rw-r-- 1 ubuntu ubuntu 8252 Sep 9 13:21 wp-mail.php -rw-rw-r-- 1 ubuntu ubuntu 11062 Sep 16 17:23 wp-settings.php -rw-rw-r-- 1 ubuntu ubuntu 25124 Sep 16 17:23 wp-signup.php -rw-rw-r-- 1 ubuntu ubuntu 4035 Sep 9 13:21 wp-trackback.php -rw-rw-r-- 1 ubuntu ubuntu 3055 Sep 16 17:23 xmlrpc.php


推荐答案

故宫403 简单的说就是有一些问题的权限。当服务器试图访问所请求的资源,那么它被限制由于权限问题,所以那些谁曾建议关于修改索引人甚至还没有接近,因为索引选项来控制目录列表。下面是摘录约 索引来自Apache 选项

Forbidden 403 simply means that there is some problem with permissions. When server is trying to access the requested resource then it is being restricted due to permission issues, so those who were advising on modifying Indexes weren't even close because Indexes option is to control the directory listing. Below is excerpt about Indexes option from Apache

如果映射到一个目录的URL请求并且没有   的DirectoryIndex(如index.html的),在该目录中,然后   mod_autoindex将返回目录的格式化列表。

If a URL which maps to a directory is requested and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.

您的问题显然根本原因是权限。

现在,为解决方案的一部分 - 因为我不知道你的所有内容的的.htaccess dev.conf ,所以下面的是我一步一步的方法:

Now, for the solution part - since I don't know your all the content of your .htaccess and dev.conf, so below your be my step by step approach:

  1. 尝试下面code段。我想禁用的.htaccess 文件的效果,看看这是根本原因。如果一切正常,那么你检讨你的的.htaccess 所有可能的问题的内容。

  1. Try below code snippet. I am trying to disable your .htaccess files effect and see if that's root cause. If it works then you to review all the content of your .htaccess for possible issue.

<Directory /var/www/dev/>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

  • 尝试下面code段。从所有为目录默认的Apache访问允许,所以我删除它,并让默认生效,并没有顺序。 。反正你也想同样的事情。

  • Try below code snippet. Default Apache access for Directory is Allow from All, so I am removing it and let default take effect and no ordering .. Anyways you were also trying same thing ..

    <Directory /var/www/dev/>
            Options -Indexes +FollowSymLinks
            AllowOverride All
    </Directory>
    

  • 在一个侧面说明,我建议第一次尝试做搭配chmod 777 为你的web应用程序的目录和文件,因为在大多数情况下,许可的问题是,因为UNIX权限而不是Apache的权限。

    On a side note, I would suggest that first try to do chmod 777 for your web app directories and files, because in most cases permission issue is because of UNIX permissions and not Apache permissions.


    跟帖编辑:
    为了进一步调试,我们将需要服务器错误的信息,您可以启用最大调试,并从 error.log中的access.log (如果从SSL记录HTTPS访问的话)。 参考

    Followup edit:
    For further debugging we will need server error info, can you enable maximum debugging and get the content from error.log and access.log (if HTTPS access then from ssl log). Reference

    此外,您可以请提供上下文的DirectoryIndex 指令和URL所使用。

    Also, could you please provide context of DirectoryIndex directive and URL you are using.

    所有的赔率是,你有权限的问题,可能是因为Apache或UNIX的。

    All odds are that you have permission issue, may be because of Apache or UNIX.

    因此​​,让第一个COM prehensively排除UNIX权限的问题,所以暂时尝试搭配chmod 777 为你的web应用程序资源,如果它的工作原理,我们知道这是UNIX权限问题,我们将看到下一步该怎么做。

    So, lets first comprehensively rule out UNIX permissions issue, so momentarily try out chmod 777 for your web app resource, if it works we know it is UNIX permission issue and we will see what to do next.

    我越来越怀疑的RewriteBase / 重写规则。的index.php [L] 的.htaccess 文件。
    举一个尝试的RewriteBase的/ var / WWW的/ dev 或任何你觉得可以更相关,但不是 /
    此外,试图玩弄重写规则,所以不是尝试绝对路径的index.php ,所以使用重写规则。 /var/www/dev/<<XYZ>>/index.php

    I am getting skeptical about RewriteBase / and RewriteRule . /index.php [L] in your .htaccess file .
    Give a try to RewriteBase /var/www/dev or whatever you think could be more relevant but NOT /
    Also, try to play around with RewriteRule, so instead try absolute path of index.php, so use RewriteRule . /var/www/dev/<<XYZ>>/index.php

    使用精确的下方,如果你没有 mod_cgi一样模块包含,那么你可能需要给一个尝试。

    Give a try using exact below, if you don't have mod_cgi module included then you may need to.

    <Directory "/home/domain/www">
            Options +Indexes FollowSymLinks +ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
    



    对于那些谁正在寻找解决方案 - 一旦OP使用递归获准搭配chmod -R WWW:数据,他可以解决这个问题。因此,得出结论 - 这个问题是因为Apache的配置,但由于UNIX权限的不行。阅读OP的评论下面的更多细节。

    For those who are looking for solution - once OP recursively granted permission using chmod -R www:data, he could solve this issue. So, to conclude - this issue was not because of Apache configuration but because of UNIX permissions. Read OP's comments below for more details.

    这篇关于403紫禁城,中/捕获22指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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