回頭把 IIS 7 下的實現方法也帖上。
環境:
操作系統:Windows 2003 Server SP2
PHP 版本:php-5.2.6-Win32
1.下載 FastCGI For IIS6
?FamilyID=2d481579-9a7c-4632-b6e6-dee9097f9dc5&displaylang=en
下載之后,雙擊運行進行安裝。
安裝后在 C:/WINDOWS/system32/inetsrv 目錄下產生了五個文件。如下圖:
同時在 IIS 的 “Web 服務擴展”里多了 FastCGI Handler。
2.下載 PHP5.25 Windows 版
下載 .zip 格式的版本,下載后解壓至 D:/PHP 目錄,并給 IIS 啟動帳戶組或用戶賦予讀取和運行權限。如下圖:
你可以根據自己的意愿解壓到別的目錄。
3. 注冊 PHP 到 FastCGI
打開 C:/WINDOWS/system32/inetsrv/fcgiext.ini 文件。
; This is the configuration file for the FastCGI handler for IIS 6.0.
; The FastCGI handler will look for this file in the same directory as
; fcgiext.dll. By default, the FastCGI installer will place this file into
; the %windir%/system32/inetsrv directory.
我個人的理解是,只要“Web 服務擴展”里的 FastCGI Handler 為允許時,在加載 fcgiext.dll 時,會讀取 fcgiext.ini 配置文件的內容,根據里面的配置為每個網站提供映射。
在 [Types] 下添加以下配置:
[Types]
php=PHP
[PHP]
ExePath=D:/PHP/php-cgi.exe
“php”表示擴展名,“PHP”是配置節名稱,以“[PHP]”定義。
4. 配置 php.ini
將 D:/PHP/php.ini-recommended 復制一個,然后重命名為 D:/PHP/php.ini
打開 D:/PHP/php.ini,修改:
extension_dir = "D:/PHP/ext"
fastcgi.impersonate = 1
其它的根據實際需要對 php.ini 進行設置修改,這里只針對能跑 php,修改完記得重啟 IIS。
5. 配置網站
右鍵網站 => 屬性 => 主目錄 => 配置 => 添加,如下圖配置:
可執行文件路徑:C:/WINDOWS/system32/inetsrv/fcgiext.dll
6. 寫個 php 測試下吧
<?php
phpinfo();
?>
看到類似以下效果說明你的服務器可以跑 php 了。
打開后如果出現提示:
No input file specified.
估計是沒配置 fastcgi.impersonate。
如果你還覺得麻煩,那就到 下載 Zend Core,這個就什么都不用配置,安裝完就可以使用了,連 MySQL 都有。
新聞熱點
疑難解答
圖片精選