0

好的。想分享这个 - 我花了 10 个小时才弄清楚。

我已经按照此处的良好说明正确安装了 mod-xsendfile 。

我还在 /etc/httpd/conf/httpd.conf 文件中正确配置了 xsendfile,添加了设置: XSendFile on XSendFilePath /var/files_need_valid_session_to_view/

而且我知道生成 X-SENDFILE 标头的代码是正确的:它在不同的服务器上工作。但是,无论我做什么,我都会收到 404 错误。 我的操作系统是 CentOS 6.4 final。

4

2 回答 2

2

使用正确的 SELinux 标签标记您的目录。请参阅如何标记与文件夹“/var/files_need_valid_session_to_view/”相同的 apache 目录。

禁用 SELinux 是不必要的安全风险。

于 2013-11-06T10:15:07.510 回答
0

禁用 SELinux解决了这个问题。我敢肯定,如果这是一个生产服务器,我应该配置 SELinux 以允许 Apache 查看/var/files_need_valid_session_to_view/,但就我的目的而言,这已经足够了。

$ sudo su
  -or-
$ su
# echo 0 >/selinux/enforce    // Note - you cannot just say sudo for this line: the stuff after the carrot will not be super-user.  sudo su, then do this.

-to perminantly disable, across reboots, see the link at the top of my answer-
于 2013-11-05T23:33:40.107 回答