-1

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?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
user6595
  • 119
  • 2
  • 9

2 Answers2

2

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.

kristofferR
  • 146
  • 3
2

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.