0

I'm trying to install x_sendfile in apache web server on a Mac OS X Server. Everything seems fine with the installation and the httpd.conf is configured with "LoadModule xsendfile_module libexec/apache2/mod_xsendfile.so" and "XSendFile ON".

If I run "httpd -M" from the terminal I can se "xsendfile_module (shared)" in the list.

But in phpinfo() or apache_get_modules() x-sendfile is not listed. If i try to use x-sendfile in my php code to download any file, the browser just downloads a 0 kb file. I can see the x-sendfile header tag in the header data though.

Any suggestions?

einord
  • 2,278
  • 2
  • 20
  • 26

2 Answers2

1

Make sure you have this line in your httpd.conf file. Add it under settings for your page:

<Directory "/var/www/html">
    XSendFile On
    XSendFilePath /dir-where-the-file-gets-downloaded-from/
<Directory>
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
store9000
  • 11
  • 1
  • This I have done already. Is there no way to try to force load a module from the terminal to see what happens? I get no errors in the log. – einord Sep 13 '12 at 14:26
1

I encountered a similar issue with CentOS. I added:

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

to the httpd.conf, however I also made sure to use absolute paths on the PHP page itself

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'");

As far as I can tell if httpd -M is showing the module as installed, the code above should work. You will not see xsendfile in phpinfo because it is not an extension of PHP. I can't speak to apache_get_modules().

Again, this is a comment based on my personal experience and not intended to be a definitive answer.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
Jesse Adam
  • 415
  • 3
  • 14