A
default installation of FastCGI on cPanel server is
dangerously simple. It’s dangerous because one cPanel account (or one vhost) is
capable of crashing down a whole server if, say, traffic were to spike up. It’s also
simple because it won’t allow complex scripts to run cleanly. In brief, it’s
absolutely not ready for production as-is. In this post, I’ll go over what it
takes to configure FastCGI on a cPanel node properly.
The
following is a list of settings that you need to add to /etc/httpd/conf/php.conf
upon switching to FastCGI:
MaxRequestsPerProcess
1000
FcgidMaxProcesses 200
FcgidProcessLifeTime 7200
MaxProcessCount 500
FcgidIOTimeout 400
FcgidIdleTimeout 600
FcgidIdleScanInterval 90
FcgidBusyTimeout 300
FcgidBusyScanInterval 80
ErrorScanInterval 3
ZombieScanInterval 3
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 3
MaxRequestLen 20468982
FcgidMaxProcesses 200
FcgidProcessLifeTime 7200
MaxProcessCount 500
FcgidIOTimeout 400
FcgidIdleTimeout 600
FcgidIdleScanInterval 90
FcgidBusyTimeout 300
FcgidBusyScanInterval 80
ErrorScanInterval 3
ZombieScanInterval 3
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 3
MaxRequestLen 20468982
You’re
more likely to adjust the settings in bold above. DefaultMinClassProcessCount
0 instructs FastCGI to keep zero PHP processes running for user when
traffic is idle (cPanel account user) . On the other
hand, DefaultMaxClassProcessCount 3 tells FastCGI to
never allow more than 3 PHP processes running at a time. This settings prevents
one users from crashing the server were they to receive a lot of traffic.
So
go ahead and copy/paste the above into your httpd.conf and restart Apache
(service httpd restart). You’re good to go now!
Distill
and rebuild Apache, then restart Apache
root@server[#] /usr/local/cpanel/bin/apache_conf_distiller --update
root@server[#] /scripts/rebuildhttpdconf
root@server[#] /etc/init.d/httpd restart
root@server[#] /scripts/rebuildhttpdconf
root@server[#] /etc/init.d/httpd restart
/etc/httpd/conf/php.conf
# Fastcgi configuration for PHP5
LoadModule fcgid_module modules/mod_fcgid.so
MaxRequestsPerProcess 500
DefaultMinClassProcessCount 0
DefaultMaxClassProcessCount 2
MaxRequestLen 204689820
FcgidConnectTimeout 150
FcgidIdleScanInterval 90
FcgidIOTimeout 150
AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml