using mod_fcgid instead of mod_php

mod_php:

  • a bit faster, than mod_fcgid
  • runs under httpd process
  • have access to apache api ( de.php.net/manual/en/ref.apache.php )
  • bad for shared hosting, since all domains run under the same user

mod_fcgid:

  • scripts runs under the user you want (good for shared hosting)
  • enhanced security
  • can run more than just php
  • you can rund multiple php versions i.e. php4, php5, php5.1, php5.2, php 5.3

On my shared hosting platform I use FastCGI to run PHP through rather than calling it directly. They run PHP via CGI by default rather than as a module so for me it was just a matter of adding the following to my .htaccess file:

 AddHandler application/myphp .php
 Action application/myphp /cgi-bin/myphp.fcgi

Next I had to create the myphp.fcgi script in my cgi-bin directory containing:

#!/bin/sh

# This ensures PHP doesn't try to run it's own
# process manager.
export PHP_FCGI_CHILDREN=0

# Replace this shell image with a PHP
# image.
exec /path/to/php -c /path/to/my/php.ini

This runs flawlessly for me and my hosting environment is running within a cluster of almost a dozen servers behind a hardware load balancer.