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.

Is there any good tutos there?

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

share|improve this question

2 Answers 2

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/mod_fastcgi.so

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
</Directory>

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:

#!/bin/bash
### Set PATH ###
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=0
PHP_FCGI_MAX_REQUESTS=1000
### no editing below ###
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
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
1  
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

 
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.