Jan 29, 2013

How to configure fastcgi(mod_fcgid) for apache.

Install mod_fcgid if not yet install.
yum install mod_fcgid

Edit http.conf, but be sure to backup before do any changes.
DocumentRoot "/var/www/html"

# 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

.....

<Document "/var/www/html">
AddHandler fcgid-script .php
Options +ExecCGI
FcgidWrapper /usr/bin/php-wrapper .php

.......

</Document>

As you notice I did not use an Alias to specific directory. Since, I decide to use fast-cgi rather than mod_php, I modify Document either.


Create the wrapper file /user/bin/php-cgi-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/bin/php-cgi

Change the wrapper permission to executable.
chmod 755 /user/bin/php-cgi-wrapper

No comments: