1、下载mod_fcgid, http://httpd.apache.org/download.cgi
2、解压之,得到mod_fcgid.so,将它移至apache安装目录下的modules下
3、在Apache配置文件中增加以下条目
参数为数字的条目可以自行调整参数值
LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .php
Options +ExecCGI
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1001
FcgidMaxRequestsPerProcess 1000
FcgidIOTimeout 300
FcgidIdleTimeout 300
FcgidMaxRequestLen 1073741824
4、修改vhosts.conf,在Apache中配置虚拟主机,为每个虚拟主机指定不同版本的PHP
其中FcgidWrapper后面的参数根据实际情况修改为php-cgi.exe的真实路径
注意php-cgi.exe路径不能包含空格或者英文字符以外的字符。
#测试
<VirtualHost *:80>
DocumentRoot "${SRVROOT}/htdocs/php56"
ServerName php56.com:80
ErrorLog "logs/php56-error.log"
FcgidWrapper "D:/WAMP/PHP/php5.6.40/php-cgi.exe"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "${SRVROOT}/htdocs/php70"
ServerName php70.com:80
ErrorLog "logs/php70-error.log"
FcgidWrapper "D:/WAMP/PHP/php7.0.33/php-cgi.exe"
</VirtualHost>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<Directory "D:/WAMP/Apache24/htdocs/">
Options +Includes -Indexes
AllowOverride All
Require all granted
</Directory>
#为站点根目录的Options增加ExecCGI
<Directory "D:/WAMP/Apache24/htdocs/">
AllowOverride All
Options -Indexes +ExecCGI
</Directory>