Question: 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

Answer: 
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
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