Apache 默认 apache2handler 方式运行处理php.
下面说切换方法:
1、下载fastcgi模块,打开https://www.apachelounge.com/download/选择相应的VC版本下载,我的使用VC14编译的,所以选的是VC14版本
2、下载解压后,将mod_fcgid.so文件复制到Apache的安装路径modules目录中
3、打开配置文件httpd.conf,添加以下代码
LoadModule fcgid_module modules/mod_fcgid.so <IfModule fcgid_module> FcgidIOTimeout 60 FcgidConnectTimeout 30 FcgidMaxProcesses 8 FcgidOutputBufferSize 64 ProcessLifeTime 240 FcgidMaxRequestsPerProcess 500 FcgidMinProcessesPerClass 0 Options ExecCGI AddHandler fcgid-script .php #你项目php安装目录 FcgidWrapper "D:/wamp/bin/php/php7.0.23/php-cgi.exe" .php </IfModule>
这个时候重启Apache就已经切换完成了
不过我配置了虚拟主机,所以还得对虚拟主机做更改
4、原虚拟主机配置
<VirtualHost *:80> ServerName myphalcon.com ServerAlias myphalcon.com DocumentRoot "${INSTALL_DIR}/www/myphalcon/public" <Directory "${INSTALL_DIR}/www/myphalcon/public/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost>
更改后(ExecCGI就是刚才配置的Options)
<VirtualHost *:80> ServerName myphalcon.com ServerAlias myphalcon.com DocumentRoot "${INSTALL_DIR}/www/myphalcon/public" <Directory "${INSTALL_DIR}/www/myphalcon/public/"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require local </Directory> </VirtualHost>
如果需要设置成不同的php版本,可以在模块中添加
FcgidWrapper "D:/wamp/bin/php/php5.6.31/php-cgi.exe -c D:/wamp/bin/php/php5.6.31/phpForApache.ini" .php
即
<VirtualHost *:80> ServerName localhost ServerAlias localhost DocumentRoot "${INSTALL_DIR}/www" <Directory "${INSTALL_DIR}/www/"> Options +Indexes +Includes +FollowSymLinks +MultiViews #Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require local FcgidWrapper "D:/wamp/bin/php/php5.6.31/php-cgi.exe -c D:/wamp/bin/php/php5.6.31/phpForApache.ini" .php </Directory> </VirtualHost>
5、重启Apache
转: https://blog.csdn.net/u014691098/article/details/80159574