Apache 默認 apache2handler 方式運行處理php.php
下面說切換方法:
一、下載fastcgi模塊,打開https://www.apachelounge.com/download/選擇相應的VC版本下載,個人使用VC14編譯的,因此選的是VC14版本
二、下載解壓後,將mod_fcgid.so文件複製到Apache的安裝路徑modules目錄中
三、打開配置文件httpd.conf,添加如下代碼
apache
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就已經切換完成了
不過我配置了虛擬主機,因此還得對虛擬主機作更改
四、原虛擬主機配置php7
<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)app
<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版本,能夠在模塊中添加ide
FcgidWrapper "D:/wamp/bin/php/php5.6.31/php-cgi.exe -c D:/wamp/bin/php/php5.6.31/phpForApache.ini" .php
即ui
<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>
五、重啓Apache spa
轉: https://blog.csdn.net/u014691098/article/details/80159574.net