httpd禁止访问未在/ var / www / html /中创建的文件

问题描述

我正在和一个Web服务器一起玩,遇到了一个特殊的问题。我有一台全新的Centos7 httpd(Apache)网络服务器。

如果按以下顺序运行:

sudo vi /var/www/html/ first.html
# enter "<p>hello</p>" and save

然后按{IP Address}/first.html即可正常运行,并在浏览器中显示“ hello”。 但是当我这样做时:

sudo vi /home/centos/second.html
# enter "<p>hello</p>" and save
sudo mv /home/centos/second.html /var/www/html/second.html

然后按{IP Address}/second.html会返回403 Forbidden You don't have permission to access/second.html on this server.

我执行了ls -al作为输出:

-rw-r--r--. 1 root root 13 Aug 18 23:33 first.html
-rw-r--r--. 1 root root 13 Aug 18 23:34 second.html

然后我执行了十六进制转储,以确认以下输出的每个位都相同:

[centos@ip-172-31-10-192 html]$ hexdump -C first.html 
00000000  3c 70 3e 68 65 6c 6c 6f  3c 2f 70 3e 0a           |<p>hello</p>.|
0000000d
[centos@ip-172-31-10-192 html]$ hexdump -C second.html 
00000000  3c 70 3e 68 65 6c 6c 6f  3c 2f 70 3e 0a           |<p>hello</p>.|
0000000d

如您所见,文件本身没有差异。现在,我假设创建过程以某种方式编辑了一些配置文件,从而可以访问first.html而不是second.html,因此我运行了grep -rin "first" /etc/httpd/grep -rin "second" /etc/httpd/并没有找到相关的输出。那么到底发生了什么?为什么通过vi创建的html文件与直接通过mv创建的相同文件有不同的处理方式?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)