apache x_sendfile未加载

dddzy1tm  于 2023-01-21  发布在  Apache
关注(0)|答案(2)|浏览(109)

我尝试在Mac OS X服务器上的apache Web服务器中安装x_sendfile。安装过程中一切似乎都很好,并且httpd.conf配置为**“LoadModule xsendfile_module libexec/apache2/mod_xsendfile.so”“XSendFile ON”
如果我从终端运行
“httpd -M”,我可以在列表中看到“xsendfile_module(shared)"**。
但是在phpinfo()或apache_get_modules()中没有列出x-sendfile.如果我尝试在我的php代码中使用x-sendfile来下载任何文件,浏览器只会下载一个0 kb的文件.不过我可以在头数据中看到x-sendfile头标记.
有什么建议吗?

8iwquhpp

8iwquhpp1#

我在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()对话。
同样,这是一个基于我个人经验的评论,并不打算成为一个确定的答案。

qlzsbp2j

qlzsbp2j2#

确保httpd.conf文件中包含此行。将其添加到页面设置下:

<Directory "/var/www/html">
    XSendFile On
    XSendFilePath /dir-where-the-file-gets-downloaded-from/
<Directory>

相关问题