Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've recently moved to Apache2 / mod_fcgid / PHP from nginx / php_fpm. This is the second server on which I've made this migration, but it's used much less frequently than the first, which is working like a charm.

The problem is in the PHP processes that it's spawning. In looking at the mod_fcgid documentation, it appears that the default for killing idle processes is 300 seconds; I've changed that to 20. At this point, I'd be fine if 300 would work - but it's not happening. It's been running for nearly a day now, and server-status shows 12 active processes:

Process name: php5
Pid Active  Idle    Accesses    State
19243  84879   14420       11      Ready

Process name: php5
Pid Active  Idle    Accesses    State
20954  82143   149         22      Ready
20947  82149   149         22      Ready
20953  82143   149         13      Ready

Process name: php5
Pid Active  Idle    Accesses    State
20589  82765   23644       72      Ready

Process name: php5
Pid Active  Idle    Accesses    State
17663  86103   2034       117      Ready

Process name: php5
Pid Active  Idle    Accesses    State
19862  83961   1976        91      Ready

Process name: php5
Pid Active  Idle    Accesses    State
18495  85825   5164        18      Ready

Process name: php5
Pid Active  Idle    Accesses    State
25463  75109   23948       24      Ready

Process name: php5
Pid Active  Idle    Accesses    State
2466   60019   60016        2      Ready

Process name: php5
Pid Active  Idle    Accesses    State
20729  82541   12592       23      Ready

Process name: php5
Pid Active  Idle    Accesses    State
22135  80616   46361        6      Ready

PHP applications are not being served at this point - Apache is returning a 503. However, it is still serving the server-status module, and mod_mono/Mono 2.10 applications are still being served. The problem is with the PHP.

/etc/apache2/mods-available/fcgid.conf...

<IfModule mod_fcgid.c>
  AddHandler    fcgid-script .fcgi
  FcgidConnectTimeout 10
  FcgidMaxRequestsPerProcess 500
  FcgidIdleTimeout 20
  FcgidFixPathinfo 1
  FcgidMaxProcesses 10
</IfModule>

(heh - Max Processes isn't being respected either...) Of course, fcgid.conf is smylinked in mods-enabled.

share|improve this question
    
Whyd you switch? Just curious as ill be launching on nginx/phpfpm soon. –  iainlbc Mar 24 '11 at 4:32
1  
Every so often, all the PHP processes would go to la-la land. It took PHP-FPM a couple of minutes to figure this out, which on their high-traffic site simply isn't acceptable. Plus, the Mono FastCGI server - well, let's just say it leaves a lot to be desired. As most of my new stuff is .NET, mod_mono works much better. I'd recommend going setting your max requests for PHP at 500; that appears to be a preset limit (though you may be able to override it). –  Daniel Mar 24 '11 at 19:46
    
Thanks Daniel - –  iainlbc Mar 25 '11 at 15:51
add comment

1 Answer

Try setting the env variable:

PHP_FCGI_CHILDREN=0

in your php starter script.

mod_fcgid will take care of spawining all the processes that are needed. So no children are actually needed and those are the one usually left behind.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.