【问题标题】:x_sendfile does not loadx_sendfile 不加载
【发布时间】:2012-09-08 20:18:03
【问题描述】:

我正在尝试在 Mac OS X 服务器上的 apache Web 服务器中安装 x_sendfile。 安装一切似乎都很好,并且 httpd.conf 配置了 "LoadModule xsendfile_module libexec/apache2/mod_xsendfile.so"“XSendFile 开启”

如果我从终端运行 "httpd -M",我可以在列表中找到 "xsendfile_module (shared)"

但是在 phpinfo() 或 apache_get_modules() 中没有列出 x-sendfile。如果我尝试在我的 php 代码中使用 x-sendfile 来下载任何文件,浏览器只会下载一个 0 kb 的文件。 我可以在标头数据中看到 x-sendfile 标头标签。

有什么建议吗?

【问题讨论】:

    标签: php apache module x-sendfile


    【解决方案1】:

    确保您的 httpd.conf 文件中有这一行。在页面的设置下添加它:

    XSendFile 开启 XSendFilePath /dir-where-the-file-gets-downloaded-from/

    【讨论】:

    • 这个我已经做了。有没有办法尝试从终端强制加载模块以查看会发生什么?我在日志中没有错误。
    【解决方案2】:

    我在使用 CentOS 时遇到了类似的问题。我补充说:

    XSendFile On 
    XSendFilePath /dir-where-the-file-gets-downloaded-from/
    

    到 httpd.conf,但是我也确保在 php 页面本身上使用绝对路径

    header('Content-Type: '.$formatMIME);
    header("Content-Transfer-Encoding: Binary"); 
    header("Content-disposition: attachment; filename=User_sees_this.pdf"); 
    header("X-Sendfile: 'absolute_path_goes_here'");
    

    据我所知,如果 httpd -M 显示模块已安装,上面的代码应该可以工作。您不会在 phpinfo 中看到 xsendfile,因为它不是 php 的扩展。我不能和 apache_get_modules() 说话。

    同样,这是基于我个人经验的评论,并不打算成为明确的答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2014-02-05
      • 2019-09-19
      • 2019-10-05
      • 2022-01-20
      • 2013-01-30
      相关资源
      最近更新 更多