HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=27)
-   -   Intermittent 500 responses in access.log without corresponding entries in error.log (http://www.howtoforge.com/forums/showthread.php?t=59262)

cbj4074 26th October 2012 20:44

Intermittent 500 responses in access.log without corresponding entries in error.log
 
Hello,

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:

http://serverfault.com/questions/219...ttently/442768

http://mail-archives.apache.org/mod_...torrent.org%3E

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):

Configuration directives
Code:

# FcgidMaxRequestsPerProcess should be <= PHP_FCGI_MAX_REQUESTS
# The example PHP wrapper script overrides the default PHP setting.
FcgidMaxRequestsPerProcess 10000

# Uncomment the following line if cgi.fix_pathinfo is set to 1 in
# php.ini:
# FcgidFixPathinfo 1

Alias /phpapp/ /usr/local/phpapp/
<Location /phpapp/>
AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /usr/local/bin/php-wrapper .php

# Customize the next two directives for your requirements.
Order allow,deny
Allow from all
</Location>

PHP wrapper script - /usr/local/bin/php-wrapper
Code:

#!/bin/sh
# Set desired PHP_FCGI_* environment variables.
# Example:
# PHP FastCGI processes exit after 500 requests by default.
PHP_FCGI_MAX_REQUESTS=10000
export PHP_FCGI_MAX_REQUESTS

# Replace with the path to your FastCGI-enabled PHP executable
exec /usr/local/bin/php-cgi

Thanks for any help here!

cbj4074 29th October 2012 16:07

It seems that pasting the following directive into the site's "Apache Directives" box resolves the issue:

Code:

<IfModule mod_fcgid.c>
FcgidMaxRequestsPerProcess 5000
</IfModule>

The directive value, 5000, is equal to the value that is defined in System -> Server Config -> example.com -> FastCGI [tab] -> FastCGI max. Requests.

Given that this problem emerges in a default ISPConfig installation, my humble opinion is that this should be fixed in ISPConfig. That is to say, ISPConfig should automatically add "FcgidMaxRequestsPerProcess 5000" to each site's virtual host configuration (where 5000 is the value defined for "FcgidMaxRequests", via the interface):

Code:

<IfModule mod_fcgid.c>
        FcgidIdleTimeout 300
        FcgidProcessLifeTime 3600
        # FcgidMaxProcesses 1000
        FcgidMaxRequestsPerProcess 5000
        FcgidMinProcessesPerClass 0
        FcgidMaxProcessesPerClass 100
        FcgidConnectTimeout 3
        FcgidIOTimeout 360
        FcgidBusyTimeout 300
        FcgidMaxRequestLen 1073741824
</IfModule>

Better yet would be to add another field, "FastCGI max. Requests per Process", to the FastCGI configuration interface, so that this value may be controlled independently of "FcgidMaxRequestsPerProcess".

I have added a thorough explanation of this problem to the relevant ServerFault question at http://serverfault.com/a/442768/142864 .

till 29th October 2012 16:18

Thanks for your investigation and solution of the problem. I've added it to the bugtracker so that we can fix it for the 3.0.5 release.


All times are GMT +2. The time now is 07:21.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.