Changing PHP FCGId sub-processes

How do I change the number of fcgid sub-processes for a virtual server?

I know that this can be defined in the server template but how do I change it for a virtual server that has already been created?

Also, in which file is this setting implemented?

I think you actually discovered a bug there…

I just tested it. In a newly created domain, if the “Default PHP execution mode” is set to FCGId in the template, a config option to change the number of processes appears in Server Configuration -> Website Options, right under the “active” PHP Execution Mode.

When the initial execution mode was mod_php5, that option does not appear, even when I set the mode to FCGId later, and even when I turn the Apache Website feature off and on again.

I’m gonna report this in the issue tracker, except Eric already notices it here and informs the coders. :slight_smile:

After another test, I found out that not the setting for the initial execution mode is the culprit, but the setting for the initial number of processes in the template.

When that is set to “None” during domain creation, the setting to change the number of processes does not appear for the domain, no matter what I change (see previous post).

To answer your second question: By empirical experimentation :slight_smile: I found out that the setting for the number of child processes is stored in (and parsed from) the file /home/domainname/fcgi-bin/php5.fcgi, in the form of an environment variable assignment like so:


with n being the number of children. If this line in the fcgi file is missing, the respective setting in Vmin does not appear and it is assumed as “None”.

This means: You can circumvent this bug by manually adding the line to the mentioned file. I assume it has to be before the export PHP_FCGI_CHILDREN line.

Also note: The php5.fcgi file by default has the immutable file system bit set, which causes the file to be literally immutable = unchangeable, which even applies to the root user! To be able to edit this file, you first need to clear the immutable bit:

chattr -i php5.fcgi

(It had taken me, about two weeks ago, about an hour of digging into the depths of the Linux filesystem to find that one out, so you can now profit from that information. :wink: )


Thanks for that information. But I discovered something on apache’s website:

PHP child process management (PHP_FCGI_CHILDREN) should always be disabled with mod_fcgid, which will only route one request at a time to application processes it has spawned; thus, any child processes created by PHP will not be used effectively. (Additionally, the PHP child processes may not be terminated properly.) By default, and with the environment variable setting PHP_FCGI_CHILDREN=0, PHP child process management is disabled.

So I think the correct way to fix this bug is to eliminate changing PHP_FCGI_CHILDREN control completely while using fcgid. It should be kept to zero.

The only time you should allow php5-cgi process to spawn child php processes is you’ve limited the number of php5-cgi instances for per virtual server to one. But that defeats the point of using fcgid as it won’t be able to handle concurrent requests.

The right directive to use is ‘DefaultMaxClassProcessCount’ as documented here:

Yep, that’s what the developers said too. They’re removing that option from the config for the next version.

Great, but I can’t figure how to limit the number of php5-cgi processes spawned while using fcgid.

According to this page

I should be able to write the code below in the virtualhost and limit the number of spawned processes to two. But if 10 concurrent requests happen, then 10 php5-cgi processes are spawned.

DefaultMaxClassProcessCount 2