einord
einord

Reputation: 2322

x_sendfile does not load

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?

Upvotes: 0

Views: 622

Answers (2)

store9000
store9000

Reputation: 11

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>

Upvotes: 1

Jesse Adam
Jesse Adam

Reputation: 415

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.

Upvotes: 1

Related Questions