We have a problem on Debian server and PHP version 4.4.4-8+etch6. In this script (it is full script, not just part of code):
mysql_connect('localhost', 'user', 'pass');
session_start();
$h = fopen('http://www.google.com/robots.txt', 'r');
var_dump(fread($h, 40));
If I comment out mysql_connect, it works. If i comment out session_start, it works.
If mysql_connect failed (bad user and password) fopen works too. But with both, fopen failed. So it is not related to DNS lookup.
There is a result
Warning: fopen(http://www.google.com/robots.txt) [function.fopen]: failed to open stream: HTTP request failed! in /var/www/web4/rychtarka.cz/rychtarka.cz/test.php on line 9
Warning: fread(): supplied argument is not a valid stream resource in /var/www/web4/rychtarka.cz/rychtarka.cz/test.php on line 10
bool(false)
I think, there is some resources limit in system, file descriptors or something. Our server administrator told us, it is skript error. Can you please point me to debian system change to repair.
Thank you for any advice.
Finally (after 3 days) we fixed the error. We traced it using ‘php -f test.php’ which pointed to Apache’s limit on max open files.
We raised number via
ulimitfrom 1024 to 8k and after a restart everything worked great.