index.html 的 Apache2 404 错误

Apache2 404 error for index.html

我在 \var\www\html

中有一个 index.html 文件

我的 /etc/apache2/sites-available/000-default.conf 是:

<VirtualHost *:80>

        Servername <redacted>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log 
    <Directory /var/www/html>
            AllowOverride All
    </Directory>

  <Location /alpha>
     AuthType Basic
     AuthName "Restricted Access - Authenticate"
     AuthUserFile /etc/httpd/htpasswd.users
     Require valid-user
   </Location>

   <Location /UserControl>
        AuthType Basic
        AuthName "Restricted Access - Authenticate"
        AuthUserFile /etc/httpd/htpasswd.users
        Require valid-user
   </Location>

  Redirect /alpha /alpha/
  ProxyPass /alpha/ http://127.0.0.1:3838/alpha/
  ProxyPassReverse /alpha/ http://127.0.0.1:3838/alpha/


  WSGIDaemonProcess UserControl user=ubuntu group=ubuntu threads=5
  WSGIScriptAlias / /home/ubuntu/FlaskApps/UserControl/UserControl.wsgi

  <Directory /home/ubuntu/FlaskApps/UserControl>
            WSGIProcessGroup UserControl
            WSGIApplicationGroup %{GLOBAL}
            WSGIScriptReloading On
            Order deny,allow
            #Allow from all
            Require all Granted
   </Directory>

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

但是,当我转到 http://servername 时,我得到的只是 404 错误。找不到该页面。我已经开始这样做一段时间了,不知道为什么。

就其价值而言,两者 http://myservername/alpha and http://myservername/UserControl 都可以工作,因此 apache 可以正常工作。

如有任何帮助,我们将不胜感激。

将你的文件与我的文件进行比较,并忽略你的身份验证位和代理后,你似乎缺少与文档根目录相关的节...

这是我的工作配置中的相关部分 - 将 /var/www-example.com 目录更改为您想要用于 http://site/ root 的目录...

DocumentRoot /var/www-example.com
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www-example.com/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

尝试:

<Directory /var/www/html>
    AllowOverride All
    Require all granted  # required in Apache 2.4
</Directory>

index.html 是否真的在某处指定为 DirectoryIndex?将它添加到您的虚拟主机配置中以确保。

如果这些都没有帮助,请谨慎行事,从简单的开始。删除与当前问题无关的所有内容,并使用非常基本的配置。

<VirtualHost *:80>
    Servername <redacted>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/html"            # try quoting
    DirectoryIndex index.html               # just in case
    ErrorLog /full/path/to/error.log        # fully specified
    CustomLog /full/path/to/access.log      # fully specified
    <Directory "/var/www/html">             # quoted
        AllowOverride All
        Require all granted                 # required in Apache 2.4
    </Directory>
</VirtualHost>

另外,我注意到你有这个:

Order deny,allow
#Allow from all
Require all Granted

首先,the docs 建议不要混合使用新旧格式访问控制,因此您可能想要摆脱 Order deny,allow。其次,我觉得Granted应该是小写的,granted.