Project

General

Profile

X-LIGHTTPD-send-file » History » Revision 2

Revision 1 (nitrox, 2008-12-12 15:13) → Revision 2/9 (nitrox, 2008-12-12 15:16)

h1. X-LIGHTTPD-send-file 

 Option to let lighty handle large file-downloads instead of PHP. 
 * X-LIGHTTPD-send-file (lighty v1.4) 
 * X-Sendfile: (lighty v1.5) 

 


 h3. Description 

 Let lighty handle downloads of large files instead of using PHP. 


 h3. HowTo 

 Your typicall FastCGI setup + "allow-x-send-file" => "enable" 

 <pre> 
 fastcgi.server = { 
    ".php" => { 
       "127.0.0.1" => { 
           # .... 
           "allow-x-send-file" => "enable" 
       } 
    } 
 } 
 </pre> 

 Tell PHP not to handle the file download, instead set up a header like this: 

 <pre> 
 <?php 
 /** 
  * lighttpd's feature of X-Sendfile explained. 
  *  
  * @author Björn Schotte <schotte@mayflower.de> 
  */ 
 $file_on_harddisk = "/data/vhosts/bjoern/htdocs/acbd18db4cc2f85cedef654fccc4a4d8download.tar.gz"; 
 $file_to_download = "download.tar.gz"; 
         header( "Content-Disposition: attachment; filename=\"" . $file_to_download . '"' ); 
         Header( "X-LIGHTTPD-send-file: " . $file_on_harddisk); 
 ?> 
 </pre> 


 h3. External links 

 * http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html