Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 0 down vote accepted

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
share|improve this answer
add comment

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.

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.