【问题标题】:Apache 2 Forbidden 403 Error despite "Require all granted"Apache 2 Forbidden 403 错误,尽管“要求所有授权”
【发布时间】:2020-12-17 22:39:54
【问题描述】:

我收到了明显臭名昭著的 apache 2 禁止错误 #403,我尝试按照有关该主题的指南进行操作,但似乎没有任何工作。 我正在使用 Ubuntu 服务器和 Apache 2.4.41

我的网站结构看起来像 /var/www/html/index.html

我的 apache2.conf [/etc/apache2/apache2.conf]:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

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

<Directory /var/www/html>
        Order allow,deny
        Allow from all
        Require all granted
</Directory>

我的 vhosts.conf [/etc/apache2/sites-available/000-default.conf]:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                Require all granted
        </Directory>

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

【问题讨论】:

  • 目录/var/www/html的权限如何?
  • @Nic3500 我该怎么做呢?那是 .htaccess 文件还是类似的文件?
  • 在linux层面, /var/www/html 的权限是什么?确保运行 apache 的用户具有读取和遍历 (x) 权限。
  • 太好了,我把它作为答案,如果你接受它,我将不胜感激:)

标签: apache


【解决方案1】:

我授予运行 Apache2 的用户访问 /var/www/html 文件夹的权限,然后就可以访问该网站了。

这是一个有几个权限的网址,我不知道具体是哪个负责的,但我相信是sudo chmod g+w /var/www/html https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website

【讨论】:

    【解决方案2】:

    从 Apache 的角度来看,您的配置似乎没问题。

    请验证您对/var/www/html 目录的权限。运行 Apache 的用户至少应具有读取和遍历 (x) 权限。

    【讨论】:

      猜你喜欢
      • 2014-08-24
      • 1970-01-01
      • 2022-08-02
      • 1970-01-01
      • 1970-01-01
      • 2021-11-02
      • 2020-04-28
      • 1970-01-01
      • 2012-11-27
      相关资源
      最近更新 更多