I moved to a VPS account because I need to serve some files without allowing direct linking and I found that in previous shared hosting all PHP scripts were terminated after a certain period.
After switching to VPS I’m finding a similar behavior! DH support has not been of much help and I wonder if anyone had this problem before, because VPS is not of much use to us like this.
I have a very simple PHP script that serves a file. This is the barebones efficient way of serving a file in PHP:<?php set_time_limit(0); if (ob_get_level()) ob_end_clean(); $name = 'served_file'; header('Content-length: '. filesize($name)); readfile($name); ?>
It downloads well on fast connections but requests over slower connections will always get a connection closed after about 8 minutes.
I’m serving 25MB files not bigger ones. This happens from remove machines or from an ssh shell in the server itself - for example with wget with throttling so that the requests takes over 8 minutes:
wget -v --server-response --limit-rate=30k http://server/test.php
The max_execution_time limit has also been changed in a phprc as recommended in the wiki and by support without effect.
No PHP errors are logged and the Apache log registers a “The server encountered an internal error or misconfiguration and was unable to complete your request” each time the download breaks at 8 minutes.
Using mod_xsendfile could be an workaround to this, but DH support doesn’t enable it in VPS (apparently in shared hosting they do), forcing us into custom httpd.conf (which DH does not update) which we’d like to avoid.
Can anyone help with this? Is this supposed to be happening in a VPS account in the first place?