403禁止使用不同名称但内容和权限相同的文件

我正在运行CentOS 6.3和Apache 2.2.15。

我正在使用Apache的默认设置。 我正在服务的文件在

/var/www/html 

这里有两个

 [root@gisele html]# ls -l *-production-1.0.6.pdf -r--r--r--. 1 root root 171769 Jan 1 21:12 copy-installation-production-1.0.6.pdf -r--r--r--. 1 root root 171769 Jan 1 20:59 installation-production-1.0.6.pdf 

复制文件是通过执行创build的文件

 cp installation-production-1.0.6.pdf copy-installation-production-1.0.6.pdf 

通过虚拟主机映射我正在访问这些文件。

copy-installation-production-1.0.6.pdf将服务。 installation-production-1.0.6.pdf返回403禁止。

唯一的区别是,原始文件从另一台机器复制到服务器上。

任何想法,为什么这个原始文件将不会服务,但复制将?

那么,禁用SELinux这只是一个临时的解决方法,而不是一个解决scheme。 我们不想让丹·沃尔什哭泣 ;)

尝试以下选项之一:

 chcon --reference=/var/www/html/FileThatCanBeServed /var/www/html/FileWithError403 

要么

 chcon -R --reference=/var/www/html /var/www/html/ 

要么

 chcon -R -t httpd_sys_content_t /var/www/html/ 

总是检查可用ls -lZ访问的文件的SELinux上下文,然后使用带有--reference选项的chcon将上下文复制到其他文件。

Gah,SELinux。 与这个问题相同的概率: Apache服务于某些文件,其他服务则获得403

closuresSELinux是解决scheme。

http://www.crypt.gen.nz/selinux/disable_selinux.html

CentOS安装应该有提示

 Is this machine primarily a Server (1) / Desktop (2) 1/2...? 1 Would you like to run into bizarre errors later on? Y/N...? y Installing SELinux.