奇怪的 Apache 403 问题

奇怪的 Apache 403 问题

我在 /var/www/html(在 CentOS 中)中有两个感兴趣的文件:index1.html 和 index2.html。

index1.html 是从网站下载的,并被切换为 root 并被 chmoded 为 0644。index2.html 由 root 创建,并将 index1.html 的内容复制到其中。它们具有相同的内容和相同的权限。Apache 将加载 index2.html,但将为 index1.html 返回 403 Forbidden 错误。如果我交换文件名,重命名后会出现权限问题。发生了什么?

[root@localhost html]# ls -al
total 52
drwxr-xr-x. 6 root root 4096 Jul  8 13:32 .
drwxr-xr-x. 6 root root 4096 Jul  8 12:59 ..
drw-r--r--. 2 root root 4096 Jun 26 12:14 css
-rw-r--r--. 1 root root 1558 Jul  8 11:42 dashboard.css
drw-r--r--. 2 root root 4096 Jun 26 12:14 fonts
-rw-r--r--. 1 root root 8744 Jul  8 13:12 index1.html
-rw-r--r--. 1 root root 8744 Jul  8 11:42 index2.html
drw-r--r--. 2 root root 4096 Jul  8 13:32 js
drw-r--r--. 4 root root 4096 Jun 21 18:39 PHP_Site
[root@localhost html]#

其余文件都已下载并被 chowned/chmodded,它们也都返回 403 错误。index2.html 是 apache 将加载的唯一文件。

如果我“su apache”并 cat 文件,它可以读取所有文件。

答案1

尝试更新您的 apache 共享的文件/文件夹上下文。

# restorecon -R /var/www/html/

SELinux 很有用,除非必须,否则不要关闭它。

相关内容