以 php5_module(Apache module、Apache Handler、mod_php) 方式執行。
目的:另外新增 php5.4.12 和原本的 php5.2.17 並存
解決方式:將 php5.4.12 另外以 mod_fcgid 方式執行
步驟:
- 下載 mod_fcgid.so
到 http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/ 任選一個載點,下載 mod_fcgid-2.3.6-win32-x86.zip - 解壓縮 mod_fcgid-2.3.6-win32-x86.zip,將裡面的 mod_fcgid.so 複製到 Apache的 modules 目錄底下
- 到 http://windows.php.net/download/ 下載 php-5.4.12-nts-Win32-VC9-x86.zip,解壓縮到 "D:\php-5.4.12-nts"
- 進到 "D:\php-5.4.12-nts" 資料夾,將 php.ini-production 檔名改為 php.ini
- 修改 php.ini,拿掉「; extension_dir = "ext"」 的註解,改為「extension_dir = "ext"」
- 在網站根目錄建立一資料夾(例如 D:/Apache(x86)/htdocs/php54/),後續將設定此資料夾的PHP網頁,改用 php5.4.12 來執行,而放在其他資料夾的網頁,一樣用原本的 php5.2.17 執行
- 修改 http.conf ,新增
- 重新啟動apache,此時放在 D:/Apache(x86)/htdocs/php54/ 資料夾的網頁將以 php5.4.12 mod_fcgid 來執行。而不在此目錄底下的網頁,依舊用 php5.2.17 執行。
#php5.4.12
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
#php.ini檔案的目錄
FcgidInitialEnv PHPRC "D:/php-5.4.12-nts/"
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
FcgidMaxRequestsPerProcess 1000
#php-cgi最大進程數
FcgidMaxProcesses 15
FcgidIOTimeout 120
FcgidIdleTimeout 120
<Directory "D:/Apache(x86)/htdocs/php54">
AddHandler fcgid-script .php
#php-cgi路徑
FcgidWrapper "D:/php-5.4.12-nts/php-cgi.exe" .php
Options +ExecCGI
AllowOverride None
Order allow,deny
allow from all
</Directory>
</IfModule>
補充:再多一個 php5.6 並存 (php5.2.17=>Apache module、php5.4.12=>mod_fcgid、php5.6.19=>mod_fcgid)
http.conf 設定改為
#php5.4
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
#php.ini 檔案
#FcgidInitialEnv PHPRC "D:/php-5.4.20-nts/" #這行改到 VirtualHost 裡設定
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
FcgidMaxRequestsPerProcess 1000
FcgidMaxProcesses 1500
FcgidIOTimeout 120
FcgidIdleTimeout 120
#php5.4
<Directory "D:/Apache(x86)/htdocs/php54">
AddHandler fcgid-script .php
#php-cgi 路徑
FcgidWrapper "D:/php-5.4.20-nts/php-cgi.exe" .php
Options +ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
#php5.6
<Directory "D:/Apache(x86)/htdocs/php56">
AddHandler fcgid-script .php
#php-cgi 路徑
FcgidWrapper "D:/php-5.6.19-nts/php-cgi.exe" .php
Options +ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
</IfModule>
httpd-vhosts.conf 新增一個 VirtualHost,
重點在 VirtualHost 裡面,將 FcgidInitialEnv PHPRC 設定到不同版本的 PHP 的資料夾,
以讀取該資料夾內的 php.ini 設定
#php54
<VirtualHost *:80>
FcgidInitialEnv PHPRC "D:/php-5.4.20-nts/"
ServerName php54.example.com
DocumentRoot "D:/Apache(x86)/htdocs/php54"
<Directory "D:/Apache(x86)/htdocs/php54">
DirectoryIndex index.php default.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#php56
<VirtualHost *:80>
FcgidInitialEnv PHPRC "D:/php-5.6.19-nts/"
ServerName php56.example.com
DocumentRoot "D:/Apache(x86)/htdocs/php56"
<Directory "D:/Apache(x86)/htdocs/php56">
DirectoryIndex index.php default.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
參考:
Apache, MySQL, PHP server on Windows with multiple, simultaneous PHP versions
PHP memcached的Session的使用与配置 - LAMP ≠ linux+apache+mysql+php - ITeye技术网站
沒有留言:
張貼留言