How to set PHP_FCGI_MAX_REQUESTS to unlimited so php-cgi does not die, in lighttpd?
Added by Profound over 13 years ago
Hi,
I have an issue where after a short while, all php pages stop responding, for a vhost. (I have one of these configs for each domain) - How do I set the PHP_FCGI_MAX_REQUESTS variable to unlimited please, does anyone know? I am wondering if left blank, it might default to 500?
Basically, since I am not using spawn-fcgi to manage php-cgi processes, I need the processes to stay around forever, though they seem to stop responding. The processes are still there in the process list, but all php requests for that domain time out.. Until I kill the processes and restart lighttpd. Static pages are served without issues.
I appreciate it is probably a PHP issue, and not lighttpd, but I have Googled this issue extensively, and am still scratching my head. :S
This is an example vhost config I am using..
$HTTP["host"] =~ "^(www\.domain)$" {
# Access log
accesslog.filename = "/var/log/www/domain/access.log"
- Set home directory
server.document-root = "/home/user/domain"
- Restrict PHP includes to user home directory
fastcgi.server = ( ".php" =>
(( "socket" => "/var/tmp/lighttpd/php-domain.socket",
"bin-path" => "/usr/bin/php-cgi -d open_basedir=.:/var/tmp/lighttpd:/user/domain",
"max-procs" => 1,
"idle-timeout" => 20,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "1",
"PHP_FCGI_MAX_REQUESTS" => ""
),
"bin-copy-environment" => ( "PATH", "SHELL", "USER" ),
"broken-scriptfilename" => "enable",
))
)
}
Appreciate any assistance, thanks.
Regards,
Tim
Replies (2)
RE: How to set PHP_FCGI_MAX_REQUESTS to unlimited so php-cgi does not die, in lighttpd? - Added by darix over 13 years ago
I am pretty sure that PHP_FCGI_MAX_REQUESTS has nothing to do with your problem.
- check if not all your php backends are just busy. lighty complains in the error log about overloaded fastcgi backends in that case.
- that either means:
- bad code
- overloaded DB
- you have too few php backends for your traffic. which seems very likely with your 1 process, 1 child configuration.
- if your php processes disappear completely, php is mostlikely crashing. also nothing that would be fixed by changing that setting.
in case of too few php processes:
1/(average request time in seconds) * (desired requests per second) = number of php children you want
RE: How to set PHP_FCGI_MAX_REQUESTS to unlimited so php-cgi does not die, in lighttpd? - Added by Profound over 13 years ago
Hi, I get these errors:
2012-02-08 17:11:28: (mod_fastcgi.c.2566) unexpected end-of-file (perhaps the fastcgi process died): pid: 17141 socket: unix:/tmp/domain-fastcgi.socket-0
2012-02-08 17:11:28: (mod_fastcgi.c.3352) response not received, request sent: 671 on socket: unix:/tmp/domain-fastcgi.socket-0 for /directory/file.php?, closing connection
Nothing about busy backends, and its a low traffic site. MySQL is nice and idle. I tried upping the number of processes/children, and it eventually died again anyway.
The PHP process does not disappear - It is still there, just all php requests fail, under this condition.
I should note the OS is CentOS 5, and I was running lighttpd-1.4.30 and php-5.3 - Now I have downgraded to 1.4.28 and 5.2.10 and (for now) the issue has not recurred.
I have also moved the sockets to a directory owned by only lighttpd, which I saw was recommended.
EDIT: Until now I have not noticed a dodgy file in the logs preceeding a 'crash' - But I just looked at file.php and as you predicted - BAD CODE! I've requested the customer remove or modify their code accordingly. Thanks for the reply - Nice to know someone out there cares. Have spent tooooo much time on this issue. :)
Next is to establish how to get php-cgi to enforce a max duration for scripts...
Thanks,
Tim