I’ve been running PHP in fastcgi mode with suExec for some time on about 50+ servers with different workload and various content. There are some tips and tricks that can improve the performance and increase the stability of such configuration.
- I found that in some situation – under extremely heavy load Apache2 worker MPM is not as stable as prefork – server process is crashing without and reasonable explanation in the logs. for such situations it’s better to switch back to prefork MPM by commenting out HTTPD variable in /etc/sysconfig/httpd and restarting apache (via [cci lang=”bash”]service httpd restart[/cci])
- mod_fcgid can use some additional tuning for performance/slow scripts -YMMV. What I have now in the 00-fcgid.conf is below
1234567891011121314151617181920212223242526LoadModule fcgid_module modules/mod_fcgid.so<IfModule mod_fcgid.c>ProcessLifeTime 300IPCCommTimeout 120IPCConnectTimeout 120MaxProcessCount 1500DefaultMaxClassProcessCount 1500DefaultMinClassProcessCount 0# Sane place to put sockets and shared memory fileSocketPath run/mod_fcgidSharememPath run/mod_fcgid/fcgid_shm#php suexec onlyPHP_Fix_Pathinfo_Enable 1AddType application/x-httpd-php .phpAddHandler php-fcgi .phpAction php-fcgi /fcgi-bin/php-fcgiFCGIWrapper /var/www/cgi-bin/php-fcgi .phpAlias /fcgi-bin/ /var/www/cgi-bin/<Location /fcgi-bin/>SetHandler fcgid-scriptOptions +ExecCGI</Location>DirectoryIndex index.php</IfModule>
For more in-depth parameter description please refer to this [amazon_link id=”6132769471″ target=”_blank” ]FastCGI[/amazon_link] book
- If you are running high traffic server ( I am talking about 200 000+ visitors/day) you might need to adjust php-cgi wrapper configuration to something like this.
1234...export PHP_FCGI_MAX_REQUESTS=5000export PHP_FCGI_CHILDREN=1exec /usr/bin/php-cgi
- If you were using [cci lang=”php”]$_SERVER[‘REMOTE_USER’][/cc] in your PHP scripts, you will have to start using [cci lang=”php”]$_SERVER[‘REDIRECTED_REMOTE_USER’][/cc] instead (same goes for REMOTE_SERVER).
- If you are using “stock” Centos5 php 5.1.6 then you will have to change wrapper variable [cci lang=”bash”]PHP_FCGI_CHILDREN=0[/cc] to [cci lang=”bash”]PHP_FCGI_CHILDREN=1[/cc] otherwise php-cgi will just refuse to start (corrected in php 5.2.x I think)
This gives some additional details on the configuration that is worth further investigation. I hope it will be helpful.
0 Comments.