Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What all should i do to use mod_fcgid instead of mod_php on ubuntu and centos. what are the main benefits and difference's between two

share|improve this question
so, what is it you want to replace? mod_cgi or mod_php? note that the three are different things that call different kinds of 'backend' with different protocols. – Javier Dec 22 '10 at 14:21
be aware that mod_fcgid actually has to read an entire request in before handing it to the fastcgi script - this could have significant performance issues if you are expecting large request bodies such as file attachments. – PP. Dec 23 '10 at 11:41
up vote 2 down vote accepted


  • a bit faster, than mod_fcgid
  • runs under httpd process
  • have access to apache api ( )
  • bad for shared hosting, since all domains run under the same user


  • 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
share|improve this answer
What I only miss here is how you can use fastcgi instead of mod php, so how you switch from mod php to fastcgi, which I thought was part of the question as well. – rhand Feb 27 '15 at 6:48
Many sites rely very much on apache api features and will not work without it. – sekrett Apr 22 at 8:16

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:


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

# 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.

share|improve this answer

cgi = each request starts a process and get's results back to client fcgi = application (Ruby/Django for example) or interpreter (PHP) stays running and webserver forwards requests and gets responses from it.

FastCGI is almost always faster (for stuff that supports it), however some very ancient stuff (nagios for example) needs cgi. Only real advantage of cgi is that where there is no traffic scripts cgi application does not use memory, but usually webserver is intelligent enough to shut down FastCGI app that's not used for some time, so that's not a real advantage

share|improve this answer

Your Answer


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.