2017年7月

apache 通过mod_fcgi 模块加载php

一,使用软件的详细版本信息如下:
http://www.linuxidc.com/Linux/2012-02/53418.htm
全部软件下载地址:http://yun.recallg.cn/s/ra8As549mQoJNMD
Apache/2.4.27

Apache FastCGI module(mod_fcgid/2.3.9)

PHP 5.2.17(php-cgi)
php各个版本下载地址:http://museum.php.net/php5/

二,详细的配置步骤:

1,安装mod_fcgid模块

1)Apache 模块下载地址:
http://httpd.apache.org/download.cgi#mod_fcgid

2)从源代码编译安装

[root@cp01-rdqa04-dev121-v-jiazhizhong.epc.baidu.com pay]# APXS=/opt/httpd/bin/apxs ./configure.apxs
[root@cp01-rdqa04-dev121-v-jiazhizhong.epc.baidu.com pay]# make && make install

3)修改apache的httpd.conf,加载mod_fcgid.so模块

LoadModule fcgid_module modules/mod_fcgid.so

4)在httpd.conf文件中添加mod_fcgid模块配置

<IfModule mod_fcgid.c> 
    AddHandler fcgid-script .fcgi .php 
    # Where to look for the php.ini file? 
    FcgidInitialEnv PHPRC        "/home/users/test/php" 
    # Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess 
    # to prevent php-cgi process from exiting before all requests completed 
    FcgidInitialEnv PHP_FCGI_MAX_REQUESTS      1000 
    # Maximum requests a process should handle before it is terminated 
    FcgidMaxRequestsPerProcess       1000 
    # Maximum number of PHP processes 
    FcgidMaxProcesses             15 
    # Number of seconds of idle time before a php-cgi process is terminated 
    FcgidIOTimeout             120 
    FcgidIdleTimeout                120 
    #Path to php-cgi 
    FcgidWrapper "/home/users/v_jiazhizhong/php/bin/php-cgi" .php 
    # Define the MIME-Type for ".php" files 
    AddType application/x-httpd-php .php 
</IfModule> 

4)修改httpd.conf中的,添加在 Options Indexes FollowSymLinks后面添加Includes ExecCGI。修改后如下:

<Directory "/home/users/v_jiazhizhong/pay-finance-php/lib/index"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important.  Please see 
    # http://httpd.apache.org/docs/2.4/mod/core.html#options 
    # for more information. 
 
    Options Indexes FollowSymLinks MultiViews Includes ExecCGI 
    AllowOverride None 

    Order allow,deny 
    Allow from all 
    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    #   AllowOverride FileInfo AuthConfig Limit 
    # 
    AllowOverride All 

    # 
    # Controls who can get stuff from this server. 
    # 
    Require all granted 
</Directory> 

5)配置好httpd.conf文件后保存,重启Apache,
phpinfo.jpg