Home
Chinese Info
Download (source)
Documentations
Feedback

This is a simple example of  the configuration for regular fastcgi. 

LoadModule fcgid_module modules/mod_fcgid.so

<Location /fcgid>
SetHandler fcgid-script
Options ExecCGI
allow from all
</Location>

This is a simple example of  the configuration for fastcgi-mode PHP ( UNIX )

LoadModule fcgid_module modules/mod_fcgid.so

AddType application/x-httpd-php .php

# FCGIWrapper MUST be placed in <Directory> section
<Directory /usr/local/apache2/htdocs/php>
SetHandler fcgid-script
FCGIWrapper /usr/local/bin/php
Options ExecCGI
allow from all
</Directory>

# You have to set this environment before PHP is patched
# But it's not good enought yet, there are still one more useless process...
DefaultInitEnv PHP_FCGI_CHILDREN 1

This is a simple example of  the configuration for fastcgi-mode PHP ( Windows )

LoadModule fcgid_module modules/mod_fcgid.so

AddType application/x-httpd-php .php

# FCGIWrapper MUST be placed in <Directory> section
<Directory "C:/Apache2/htdocs/php/">
SetHandler fcgid-script
Options execCGI
AllowOverride None
Order allow,deny
Allow from all
FCGIWrapper "c:/php/php.exe"
</Directory>

You can group the php scripts by the resource they are using 

For example: there are four PHP scripts: foo.php, bar.php, database1.php and database2.php.  foo.php and bar.php are simple scripts that do not connect to database, but database1.php and database2.php do. 

In "share" mode, there is only one type of PHP fastcgi process, all .php script will be run with any free fastcgi process, so, once database*.php is called, the php fastcgi process will be "polluted", and a database connection will be keep by this fastcgi php process.

If all .php are running with "non-share" mode, all .php scripts will be run separately,  This will spawn unnecessary php processes, because foo.php and bar.php can share one PHP process, database1.php and database2.php can share another.

Now you can override this dilemma with the following configuration:

<Directory /usr/local/apache2/htdocs/php>
SetHandler fcgid-script
FCGIWrapper /usr/local/bin/php
FCGIWrapperGroup /usr/local/bin/php database1.php database2.php
Options ExecCGI
allow from all
</Directory>

Now database1.php and database2.php share one group of PHP processes, and all other PHP scripts in /usr/local/apache2/htdocs/php share another.

By the way, you can setup many groups with multi-FCGIWrapperGroup setting. 

There are some other configurations you can set

IdleTimeout n (300 seconds)

An idle fastcgi application will be terminated after IdleTimeout seconds.

IdleScanInterval n (120 seconds)

The scan interval for idle fastcgi applications.

BusyTimeout n (300 seconds)

a fastcgi application will be terminated if handing a single request longer than busy timeout.

BusyScanInterval n (120 seconds)

The scan interval for busy timeout fastcgi applications.

ErrorScanInterval n (3 seconds)

The scan interval for exit pending fastcgi applications. fastcgi applications will be terminated within this scanning.

ZombieScanInterval n (3 seconds)

The scan interval for zombie process. 

ProcessLifeTime n (3600 seconds)

A fastcgi application will be terminated if lifetime expired, even no error is detected.

SocketPath path (logs/fcgidsock)

The directory to put the UNIX domain socket. (UNIX only)

SpawnScoreUpLimit n (10)

The spawn-speed control score up water limit. Score increases while a process is spawned or terminated, and decreases as time progresses; while the score is higher than SpawnScoreUpLimit, the spawning will be held for a while. The higher this number is, the higher speed of the spawning can be.

SpawnScore n (1)

The weight of spawning.  This weight will be plused to the spawn-control score on every spawn. The higher this number is, the lower speed of spawning can be.

TerminationScore n (2)

The weight of termination. This weight will be plused to the score while fastcgi process terminates. The higher this number is, the lower speed of spawning can be.

MaxProcessCount n (1000)

The max count of total fastcgi process count.

DefaultMaxClassProcessCount n (100)

The maximum number of fastcgi application instances allowed to run for any one fastcgi application. This value can be overwrite in a "<Directory>" section later.

DefaultInitEnv  env_name env_value

The default environment variables before a fastcgi application is spawned. This value can be overwrite in a "<Directory>" section later. You can set this configuration more than once.

IPCConnectTimeout n (2 seconds)

The connect timeout to a fastcgi application.

IPCCommTimeout n (5 seconds)

The communication timeout to a fastcgi application.