一,使用软件的详细版本信息如下:
Apache(apache 2.2.15)
Apache FastCGI module(mod_fcgid 2.3.6)
PHP 5.3.3(php-cgi)
相关阅读:
在RHEL 5.3(Tikanga)上配置Apache + FastCGI(mod_fastcgi) + PHP http://www.linuxidc.com/Linux/2012-02/53419.htm
二,详细的配置步骤:
(下面步骤的前提是Apache和PHP(php-cgi)均已经安装)
1,安装mod_fcgid模块
1)下载地址:
http://httpd.apache.org/download.cgi#mod_fcgid
2)从源代码编译安装
[root@www.linuxidc.com mod_fcgid-2.3.6]# whereis apxs
apxs: /opt/httpd/bin/apxs
[root@www.linuxidc.com mod_fcgid-2.3.6]# APXS=/opt/httpd/bin/apxs ./configure.apxs
[root@www.linuxidc.com mod_fcgid-2.3.6]# make
[root@www.linuxidc.com mod_fcgid-2.3.6]# make install
(使用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]
LoadModule fcgid_module modules/mod_fcgid.so
Include conf.d/php-fcgid.conf
b, 在/opt/httpd/conf.d目录下建立php-fcgid.conf
[xhtml]
# 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
# Define a new handler "php-fcgi" for ".php" files, plus the action that must follow
AddHandler php-fcgi .php
Action php-fcgi /cgi-bin/php.fcgi
c, 在/opt/cgi-bin目录下建立php.fcgi(注意修改此文件的权限为755)
[xhtml]
#!/bin/bash
# Path to php.ini
PHPRC=/usr/local/lib
### Set PATH ###
PHP_CGI=/opt/bin/php-cgi
PHP_FCGI_CHILDREN=0
PHP_FCGI_MAX_REQUESTS=1000
### no editing below ###
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI
d, 检查配置语法是否正确,然后使用apachectl重启Apache
[root@www.linuxidc.com www]# /opt/httpd/bin/apachectl configtest
Syntax OK
[root@www.linuxidc.com www]# /opt/httpd/bin/apachectl restart
e, 在/opt/httpd/www目录下建立config.inc.php,使用浏览器访问。(若配置正确,那么PHP Variables栏目下的_SERVER["SERVER_SOFTWARE"]一项的值为:Apache/2.2.15 (Unix) mod_fcgid/2.3.6)
[php]