I know it’s difficult to find good documentation to configure apache2 with mod_fastcgi and suexec to make php websites works. This configuration works well with Debian Etch (4.0).
Here an example of configuration.
/var/www/toto/: the web account of toto
/var/www/toto/web/: the web dir of the toto’s account
/var/www/toto/conf/php.ini: you own php.ini file
/var/www/toto/cgi-bin/php.fcgi: the fcgi file which allow to run php5-cgi with a specific php.ini file for each virtual host
First of all don’t forget that mod_fastcgi and mod_fcgid are different. Difference between mod_fastcgi and mod_fcgid is mostly at license level, since some might consider mod_fastcgi not to be totally free.
Enable fastcgi and suexec:
Suexec has no configuration file, because every parameter is hardcoded. Therefore, if you need to configure suexec, do it at apache2 compile time.
Let’s see how…
AP_DOC_ROOT is set to « /var/www », which is the reason you would want to put your files in /var/www/. You cannot just ignore this fact; if this directory is inconsistently set, it just won’t work. If you want to change this directory, you must recompile apache2 with your own configuration.
fastcgi.conf: (in /etc/apache2/mods-available/ for Debian)
AddHandler fastcgi-script .fcgi
FastCgiConfig -singleThreshold 1 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION
See http://www.fastcgi.com/ if you want to know about all the options possible in fastcgi.conf.
Let’s configure (in /etc/apache2/sites-available/ for debian etch) a virtual host for toto:
SuexecUserGroup UserName GroupName
Options -Indexes FollowSymLinks -MultiViews
Allow from all
ScriptAlias /cgi-bin/ /var/www/toto/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Allow from all
AddHandler php-fastcgi .php
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
Action php-fastcgi /cgi-bin/php.fcgi
Make sure to set appropriate rights for /var/www/toto/ you set in the virtual host (SuexecUserGroup), since php5-cgi will be executed with these rights.
restart apache2 :
A maximum of four php5-cgi will be launched when the first visitor will visit the website. They would be killed after a timeout of 240 seconds of inactivity, as set in fastcgi.conf.
It should work.
Please tell me know if you are aware of issue that may arise with such a configuration.