![Apache2 404 未找到文件夹中实际存在的文件错误](https://linux22.com/image/793253/Apache2%20404%20%E6%9C%AA%E6%89%BE%E5%88%B0%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%AD%E5%AE%9E%E9%99%85%E5%AD%98%E5%9C%A8%E7%9A%84%E6%96%87%E4%BB%B6%E9%94%99%E8%AF%AF.png)
在我的 ubuntu 服务器上我有用户农民里面家庭/农民目录我创建了目录 /var/www/html/ 并在 html 里面放置了文件 index.html
我已授予目录和 index.html 文件以下权限
drwxrwxr-x 3 farmer www-data 4096 Mar 1 13:26 var
drwxrwxr-x 3 farmer www-data 4096 Mar 1 13:26 www
drwxrwxr-x 2 farmer www-data 4096 Mar 1 14:00 html
-rw-r--r-- 1 farmer www-data 501 Mar 1 14:00 test.html
我在 ubuntu 上安装了 Apache2,并在目录 /etc/apache2/sites-available 中创建了配置文件 test.conf,具体说明如下
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName 64.227.177.11
ServerAlias www.64.227.177.11
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog
${APACHE_LOG_DIR}/error.log
CustomLog
${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
在 /等/apache2/apache2.conf 我创建了额外的目录指令
<Directory /var/www/test>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
配置完成后,我尝试访问我的 test.html,我运行 curlhttp://64.227.17.11/test.html但响应是 404 未找到错误,但是当我运行 curlhttp://64.227.17.11/我看到 sratus 200 apache 在 /var/www/html 中找不到 test.html 可能是什么问题?
在 var/log/apache2/error.log 中输出以下信息
[Fri Mar 01 16:23:38.573276 2024]
[core:notice] [pid 2429593] AH00094:
Command line: '/usr/sbin/apache2'
[Fri Mar 01 16:23:38.573283 2024]
[core:debug] [pid 2429593] log.c(1570): AH02639: Using SO_REUSEPORT: yes (1)
[Fri Mar 01 16:23:38.573289 2024] [mpm_prefork:debug] [pid 2429593] prefork.c(970): AH00165: Accept mutex: none (default: pthread)
[Fri Mar 01 16:23:38.573641 2024] [watchdog:debug] [pid 2429595] mod_watchdog.c(559): AH02980: Watchdog: nothing configured?
[Fri Mar 01 16:23:38.574241 2024] [watchdog:debug] [pid 2429596] mod_watchdog.c(559): AH02980: Watchdog: nothing configured?
[Fri Mar 01 16:23:38.581594 2024] [watchdog:debug] [pid 2429598] mod_watchdog.c(559): AH02980: Watchdog: nothing configured?
[Fri Mar 01 16:23:38.582444 2024] [watchdog:debug] [pid 2429597] mod_watchdog.c(559): AH02980: Watchdog: nothing configured?
[Fri Mar 01 16:23:55.379220 2024] [authz_core:debug] [pid 2429594] mod_authz_core.c(815): [client 64.227.17.11:35816] AH01626: authorization result of Require all granted: granted
[Fri Mar 01 16:23:55.379334 2024] [authz_core:debug] [pid 2429594] mod_authz_core.c(815): [client 64.227.17.11:35816] AH01626: authorization result of <RequireAny>: granted
[Fri Mar 01 16:23:55.379445 2024] [core:info] [pid 2429594] [client 64.227.17.11:35816] AH00128: File does not exist: /var/www/html/test.html