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

Is there any good tutos there?

Currently I'm using apache2/mod_php which is not efficient.

share|improve this question

Shouldn't really matter which distribution you're running but here is the setup I'm using for my CentOS server but should be able to translate easy enough for whichever you're using. You'll want to use the Worker MPM for Apache2 vs the Prefork MPM for the best results.

Assumption is that you've already installed mod_fastcgi either by distribution packaging or from source code. Once you have mod_fastcgi installed then you want to ensure it's configured to be loaded via Apache2, I did so in /etc/httpd/conf.d/mod_fastcgi.conf containing:

LoadModule fastcgi_module modules/

Next I created another file as /etc/httpd/conf.d/whatever.conf (Name whatever to anything you want really, for me it was wordpress.conf):

<Directory "/path/to/app/docroot">
    Options +ExecCGI
    AddHandler php5-fastcgi .php
    Action php5-fastcgi /cgi-bin/php.fcgi
    DirectoryIndex index.php index.html
    AllowOverride All

This then means in your cgi-bin directory (for me that is /var/www/cgi-bin/ I need to create the php.fcgi script and chmod 755 it. Mine contains:

### Set PATH ###
### no editing below ###
exec $PHP_CGI

Of course update the PHP_CGI path if it's different for your system. You can also change the PHP_FCGI_CHILDREN value, I've seen some recommend setting it to 4 but I've left it at 0 and had good performance.

At this point you should be able to give Apache2 a restart to re-read the configurations and if you setup a simple phpinfo() page to query you should see it saying the ServerAPI setting stating CGI/FastCGI.

share|improve this answer
I asked what distro because he wants a tutorial, likely a start to finish/copy paste tutorial including installation which ofcourse does vary. That being said it was nice of you devulge your config :) Out of curiosity why did you opt for fastcgi over fcgid? – iainlbc Jul 16 '10 at 18:41
Mostly because that's what I've had experience with as it's what's been available for more of the shared web hosting platforms I've used in the past so thus what I've implemented on my VPS boxes. I've not messed with fcgid. – Jeremy Bouse Jul 17 '10 at 2:53

What Distro?

Here's a tutorial for moving from mod_php to mod_fcgid on Ubuntu:

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.