【问题标题】:Ubuntu 14.04 Apache 2.4.7 404 Not FoundUbuntu 14.04 Apache 2.4.7 404 未找到
【发布时间】:2016-07-17 17:24:42
【问题描述】:

我一直在阅读论坛并尝试复制他们的修复程序,但我肯定遗漏了一些东西,因为它会从简单的 404 Error Not Found 切换到 403禁止错误(即使在 chown 和 chmod 更改后)。

目前,即使在 sudo apache2ctl restart 之后,我也遇到 403 错误代码

这是我到目前为止所做的。 - gedit apache2.conf 如下

<Directory /path/to/directory/>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>
  • gedit sites-available/000-default.conf && sites-enabled/000-default.conf

    DocumentRoot /path/to/directory
        <Directory />
            Options FollowSymLinks
            AllowOverride All
        </Directory>
        <Directory /path/to/directory>
            Options Indexes FollowSymLinks MultiViews
            Order allow,deny
            allow from all
        </Directory>
    
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            Options Indexes FollowSymLinks MultiViews
            Order allow,deny
            Allow from all
        </Directory>
    

非常感谢任何帮助。

【问题讨论】:

  • 您要访问哪个链接?服务器上是否存在您要访问的文件(也要检查拼写错误)?
  • 没有错误。我想我现在必须找到 var/www/html 下的所有文件夹。只要目录的路径相同,我就可以将文件夹重新定位到任何地方。出于某种原因,如果我找到 var/www/html/ 之外的目录,它会返回错误

标签: apache apache2 ubuntu-14.04 apache2.4


【解决方案1】:

首先请注意,您现在拥有的是 Apache 2.4,而不是 Apache 2.2。声明权限的方式在 Apache 2.4 中发生了变化,您应该始终使用新的(如 require all granted)。

Apache 在允许提供哪些文件方面变得更加严格。从本质上讲,将文件安排在您的文档根目录及以下外部提供服务,并将所有其他文件保留在此树之外。不要链接到 Document Root 树之外的文件。

你的一些配置:

 <Directory />

这是文件系统的根目录。如果你为它声明任何东西,它应该是require all denied 而不是别的。请注意,&lt;Directory /absolute/path/to/some/directory&gt; 指令和 &lt;location /relative/path/to some/location/on/your/server&gt; 指令之间存在差异。

根据&lt;location&gt; 配置您的服务器

【讨论】:

    猜你喜欢
    • 2014-11-07
    • 2014-05-24
    • 1970-01-01
    • 2015-10-15
    • 1970-01-01
    • 2016-08-06
    • 2014-07-10
    • 2015-06-22
    • 2023-03-04
    相关资源
    最近更新 更多