Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 26th October 2012, 20:44
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 392
Thanks: 29
Thanked 58 Times in 50 Posts
Default 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!

Last edited by cbj4074; 26th October 2012 at 21:23. Reason: Added example snippets from relevant documentation
Reply With Quote
Sponsored Links
  #2  
Old 29th October 2012, 16:07
cbj4074 cbj4074 is offline
Senior Member
 
Join Date: Nov 2010
Posts: 392
Thanks: 29
Thanked 58 Times in 50 Posts
Default

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 .
Reply With Quote
The Following User Says Thank You to cbj4074 For This Useful Post:
till (29th October 2012)
  #3  
Old 29th October 2012, 16:18
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,082
Thanks: 826
Thanked 5,396 Times in 4,240 Posts
 
Default

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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
cbj4074 (29th October 2012)
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
nginx & wordpress gives 500 pages EckyBrazz Server Operation 8 24th October 2012 00:06
vlogger (problem) cusco General 3 7th May 2012 15:32
Client access to access.log and error.log pavljiks Installation/Configuration 4 8th March 2011 20:33
ispconfig and mambo shajazzi Installation/Configuration 70 28th March 2006 19:29


All times are GMT +2. The time now is 17:09.


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