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

I am trying to switch to fcgi from DSO on a CentOS 5.7 x64 server. I did this within cPanel as suggested by the cPanel documentation.

Immediately, I start to get 500 internal server errors when attempting to access the site.

Upon checking my apache error logs I see the following:

[Wed Feb 01 19:00:40 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.6 configured -- resuming normal operations
[Wed Feb 01 19:00:41 2012] [notice] caught SIGTERM, shutting down
[Wed Feb 01 19:00:42 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Wed Feb 01 19:00:42 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.6 configured -- resuming normal operations
[Wed Feb 01 19:04:42 2012] [notice] Graceful restart requested, doing restart
[Wed Feb 01 19:04:42 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.6 configured -- resuming normal operations

Switching back to DSO makes everything work fine again.

How do I get this working with fcgi?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The default installation of FastCGI through WHM is not ready for use after installation. It's stupid of them, even borderline dangerous, to not tell you this since it seems like it would work automatically like almost everything else you install that way does.

The reason is quite simple - there's no FastCGI configuration file created by the WHM install process. This leaves FastCGI with stupid/dangerous default settings which results in a lot of 500 errors and the possibility of a single user to crash your whole server by just running a PHP file with some code errors or getting a lot of traffic.

Anyway, the solution is simple too. Edit /etc/httpd/conf/php.conf and add this:

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

You can google each setting to understand them better and find the suitable values for your server, but even just copying the above is way better than using the default settings that you get without a configuration file.

PS. Unfortunately this file is reset each time you update Apache, PHP or MySQL, so keep a backup that you restore after each update.

share|improve this answer
    
Brilliant... Thank you. Great, simple and articulate answer. –  user6595 Feb 22 '12 at 10:14

Please note that you can also include this in the Post VirtualHost Include of cPanel. This is done via WHM by selecting "Apache Configuration" -> "Include Editor". Then select "All Versions" in the dropdown menu under "Post VirtualHost Include".

You should then put your FCGI config like this:

<IfModule mod_fcgid.c>
FcgidProcessLifeTime 8200
FcgidIOTimeout 8200
FcgidIdleTimeout 60
...
</IfModule>

This way it will not get overwritten everytime cPanel does an update.

share|improve this answer
    
Thanks thats really useful to know :) –  user6595 Jan 29 '13 at 11:03

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.