apache上php运行主要两种方式,一种是将php以apache的模块加载,另一种是运行单独的php-cgi进程,解析php。
php模块安装相应软件包即可,如debian下apt-get install libapache2-mod-php5。

fastcgi网上可以搜索到fastcgi和fcgid两个模块,较适合使用的为fcgid,在apache项目的页面上有单独的链接页面。debian下运行apt-get install libapache2-mod-fcgid。

下面是其他相关的配置,来自apache项目上的在线文档:
----------
# FcgidMaxRequestsPerProcess should be <= PHP_FCGI_MAX_REQUESTS
# The example PHP wrapper script overrides the default PHP setting.
FcgidMaxRequestsPerProcess 10000

# Uncomment the following line if cgi.fix_pathinfo is set to 1 in
# php.ini:
# FcgidFixPathinfo 1

Alias /phpapp/ /usr/local/phpapp/
<Location /phpapp/>
AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /usr/local/bin/php-wrapper .php

# Customize the next two directives for your requirements.
Order allow,deny
Allow from all
</Location>

----------
新建的/usr/local/bin/php-wrapper
----------
PHP wrapper script - /usr/local/bin/php-wrapper
#!/bin/sh
# Set desired PHP_FCGI_* environment variables.
# Example:
# PHP FastCGI processes exit after 500 requests by default.
PHP_FCGI_MAX_REQUESTS=10000
export PHP_FCGI_MAX_REQUESTS

# Replace with the path to your FastCGI-enabled PHP executable
exec /usr/local/bin/php-cgi

----------