I am experiencing an elusive problem with mod_fcgid (Fast-CGI) for Apache. In essence, Apache's access log contains intermittent 500 responses to which there is no clear pattern.
After several hours of debugging and research, I have determined that the root cause is not a "bug", per se, nor is it a problem with my PHP scripts. Rather, it is a limitation inherent to mod_fcgid's PHP implementation.
This issue surfaces on any system that uses mod_fcgid to execute PHP scripts because the module's default configuration values are set in a way that does not prevent it. I am somewhat surprised that more ISPConfig users have not noticed this. Then again, unless the server administrator is reviewing Apache's access log(s) carefully, the issue would likely go unnoticed. I noticed it only because I use logwatch
, which sums each HTTP response code's occurrences over a given period of time. I began seeing several dozen 500 errors each day, none of which had corresponding entries in PHP's error log. This fact indicated that the problem was not with the PHP scripts.
For those curious as to the exact nature of the issue, please see my posts at the following URLs:
One possible solution to the problem requires mod_fcgid's FcgidMaxRequestsPerProcess
directive to be set to a value that is less than or equal to the value specified for the PHP_FCGI_MAX_REQUESTS environment variable (but greater than zero).
I have several questions:
1.) How/where should one specify the configuration directive value for FcgidMaxRequestsPerProcess on a sever running ISPConfig?
2.) Do PHP_FCGI_MAX_REQUESTS and FcgidMaxRequestsPerProcess represent the same directive?
3.) When are the cgi/fcgi wrapper scripts regenerated? Are these scripts regenerated only when the values in System -> Sever Config -> example.com -> CGI [tab] are modified?
I see that the PHP_FCGI_MAX_REQUESTS environment variable is defined (or overridden) in each site's Fast-CGI wrapper script (.php-fcgi-starter
I would prefer to define FcgidMaxRequestsPerProcess in much the same way (on a per-site basis).
Should this directive be defined in the "Apache Directives" text area input field on the "Options" tab (of the Web Domain interface)?
If the answer to question 2) above is "yes", then perhaps ISPConfig should be modified to define FcgidMaxRequestsPerProcess (using the value defined for "FastCGI max. Requests" within the GUI) within each virtual host's configuration.
Perhaps these excerpts from the relevant documentation ( https://httpd.apache.org/mod_fcgid/m....html#examples
) will shed some light on question 2):
# FcgidMaxRequestsPerProcess should be <= PHP_FCGI_MAX_REQUESTS
# The example PHP wrapper script overrides the default PHP setting.
# Uncomment the following line if cgi.fix_pathinfo is set to 1 in
# FcgidFixPathinfo 1
Alias /phpapp/ /usr/local/phpapp/
AddHandler fcgid-script .php
FcgidWrapper /usr/local/bin/php-wrapper .php
# Customize the next two directives for your requirements.
Allow from all
PHP wrapper script - /usr/local/bin/php-wrapper
# Set desired PHP_FCGI_* environment variables.
# PHP FastCGI processes exit after 500 requests by default.
# Replace with the path to your FastCGI-enabled PHP executable
Thanks for any help here!