软件版本:
apache:httpd-2.4.10-x86-vc11-r2
PHP:PHP 5.5.21(php-5.5.21-nts-Win32-VC11-x86.zip,因为是FastCGI方式,所以选择非线程安全版本,一般apache配合PHP是把PHP当作一个模块运行了,这种情况使用线程安全版本)
1、下载apache2.4的fastCGI的模块
下载地址:http://www.apachelounge.com/download/
选择对应的版本:modules-2.4-win32-VC11.zip (因为我这里的)
这里面除了FahstCGI模块等好几个模块,我们需要的是 mod_fcgid.so
2、把mod_fcgid.so放到apache2.4的modules目录下;
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 "c:/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 "c:/php/php-cgi.exe" .php
# Define the MIME-Type for ".php" files
AddType application/x-httpd-php .php</IfModule>
5.修改httpd.conf中的, Options Indexes FollowSymLinks后面添加Includes ExecCGI。修改后如下:
<Directory "E:/webroot">
#
# 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 Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted</Directory>