Apache, PHP, SuEXEC: lessons learned

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 service httpd restart)
  • mod_fcgid can use some additional tuning for performance/slow scripts -YMMV. What I have now in the 00-fcgid.conf is below

    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.

  • If you were using
    $_SERVER['REMOTE_USER']

    in your PHP scripts, you will have to start using

    $_SERVER['REDIRECTED_REMOTE_USER']

    instead (same goes for REMOTE_SERVER).

  • If you are using “stock” Centos5 php 5.1.6 then you will have to change wrapper variable
    PHP_FCGI_CHILDREN=0

    to

    PHP_FCGI_CHILDREN=1

    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.

Share Button

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">