一,使用软件的详细版本信息如下:

Apache(apache 2.2.15)

Apache FastCGI module(mod_fcgid 2.3.6)

PHP 5.3.3(php-cgi)

相关阅读:

二,详细的配置步骤:

(下面步骤的前提是Apache和PHP(php-cgi)均已经安装)

1,安装mod_fcgid模块

1)下载地址:

http://httpd.apache.org/download.cgi#mod_fcgid

2)从源代码编译安装

(使用updatedb手动刷新locate数据库,使用locate mod_fcgid.so检查mod_fcgid是否安装成功。)

2,配置Apache

1)查找二进制文件php-cgi的路径(这里我使用从源代码编译安装PHP 5.3.3在/opt目录下,读者可以使用locate php-cgi来查找。)

/opt/bin/php-cgi

2)修改php-cgi使用的php.ini

cgi.fix_pathinfo=1

3)修改Apache的配置文件/opt/httpd/conf/httpd.conf

a, 分别在适当位置添加添加下面两行:

[xhtml]
  1. LoadModule fcgid_module modules/mod_fcgid.so  
  2. Include conf.d/php-fcgid.conf  

b, 在/opt/httpd/conf.d目录下建立php-fcgid.conf

[xhtml]
  1. <IfModule fcgid_module>  
  2.     # FcgidMaxRequestsPerProcess should be <= PHP_FCGI_MAX_REQUESTS  
  3.     # The example PHP wrapper script overrides the default PHP setting.  
  4.     FcgidMaxRequestsPerProcess 10000  
  5.     # Uncomment the following line if cgi.fix_pathinfo is set to 1 in  
  6.     # php.ini:  
  7.     FcgidFixPathinfo 1  
  8.     # Define a new handler "php-fcgi" for ".php" files, plus the action that must follow  
  9.     AddHandler php-fcgi .php  
  10.     Action php-fcgi /cgi-bin/php.fcgi  
  11. </IfModule>  

 

c, 在/opt/cgi-bin目录下建立php.fcgi(注意修改此文件的权限为755)

[xhtml]
  1. #!/bin/bash  
  2. # Path to php.ini  
  3. PHPRC=/usr/local/lib  
  4. ### Set PATH ###  
  5. PHP_CGI=/opt/bin/php-cgi  
  6. PHP_FCGI_CHILDREN=0  
  7. PHP_FCGI_MAX_REQUESTS=1000  
  8. ### no editing below ###  
  9. export PHPRC  
  10. export PHP_FCGI_CHILDREN  
  11. export PHP_FCGI_MAX_REQUESTS  
  12. exec $PHP_CGI  

 

d, 检查配置语法是否正确,然后使用apachectl重启Apache

 

e, 在/opt/httpd/www目录下建立config.inc.php,使用浏览器访问。(若配置正确,那么PHP Variables栏目下的_SERVER["SERVER_SOFTWARE"]一项的值为:Apache/2.2.15 (Unix) mod_fcgid/2.3.6)

[php]
  1. <?php phpinfo(); ?>  

在RHEL 5.3(Tikanga)上配置Apache + FastCGI(mod_fcgid) + PHP