php - 500 error when downloading files over 63MB -


i'm not sure if php problem, server config problem or hardware problem, thought i'd start php , see if suggestions. code worked fine until recently, , i'm not aware of configuration changes might have caused this. did upgrade debian lenny squeeze (and php 5.2 5.3), code works fine on squeeze server.

i have bit of php code takes path file passed variable (rewritten via mod_rewrite request http://site.com/request/for/file.pdf http://site.com/downloader.php?path=/path/to/file.pdf). reason doing relates stats tracking.

the file passed along bit code (simplified readability).

 if(is_readable($thefile)) {         //$fh= fopen($thefile, "r");        header("cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");        header("pragma: no-cache");        header("content-type: application/pdf");        header("content-disposition: attachment; filename=\"".basename($thefile)."\"");        header("content-length:".(string)(filesize($thefile)));        sleep(1);        //fpassthru($fh);        readfile($thefile);  } 

as can see, code gets executed if file readable (ie path correct). files under 63mb, works fine. on 63mb, server returns 500 error. (this gets reported in firefox/chrome 'file not found', when guess should 'internal server error', that's story guess). there nothing in apache error logs.

can think of php or apache server configuration cause happen? php memory limits should not affected readfile or fpassthru far know. note php memory limit 64mb, however, turning off mod_rewrite redirect php not fix problem. files still won't download.

many suggestions.

updated***********

ok, increased php memory limit 64mb 200mb. allows files 200mb download. however, question remains. given readfile , fpassthru should not affected memory limit, , have checked output buffering off, why large files causing (new) problem?

resolution simple (after hours of work).

php_value output_buffering 0 

added apache virtual host config.

seems that, regardless of ob_get_level() said, output buffering taking place. in other words, option use output buffering enough affect php memory use.


Comments