Sysadmin/ApachePhpFastcgiHowto

= Installed Required Modules =

apt-get install php5-cgi libapache2-mod-fastcgi apt-get install php5-mysql
 * Assumes you already have apache2 (e.g. apache2-mpm-worker) installed.
 * 1) if you want mysql access (e.g. for wordpress ...)


 * In Ubuntu libapache2-mod-fastcgi requires enabling Multiverse repository in /etc/apt/sources.list
 * You'll also need to ensure the actions module is enabled:

a2enmod actions fastcgi a2enmod rewrite
 * 1) for mod rewrite (for wordpress ...)


 * Set up fastcgi wrapper script and install at /etc/apache2/fastcgi-php (you can change this if you wish but remember to change apache config below):

PHPRC="/etc/php5/cgi/php.ini" export PHPRC PHP_FCGI_CHILDREN=4 export PHP_FCGI_CHILDREN exec /usr/bin/php5-cgi
 * 1) !/bin/sh


 * Make sure the script is executable:

chmod +x /etc/apache2/fastcgi-php
 * Add to /etc/apache2/conf.d/fastcgi-php

FastCgiServer /etc/apache2/fastcgi-php ScriptAlias /cgi-bin/php /etc/apache2/fastcgi-php AddHandler php-fastcgi .php  SetHandler fastcgi-script SetOutputFilter stripcomments  Action php-fastcgi /cgi-bin/php AddType application/x-httpd-php .php
 * 1) See http://www.fastcgi.com/docs/faq.html#PHP (slightly modified)


 * That's it!