IIS 6 下配置以 FastCGI 跑 PHP

來源:互聯網
上載者:User

環境:
作業系統:Windows 2003 Server SP2
PHP 版本:php-5.2.6-Win32

1.下載 FastCGI For IIS6

http://www.iis.net/download/fastcgi

下載之後,雙擊運行進行安裝。

安裝後在 C:\WINDOWS\system32\inetsrv 目錄下產生了五個檔案。如:

  1. fcgiext.dll – fastcgi處理常式
  2. fcgiext.ini – 設定檔
  3. fcgiconfig.js – FastCGI的控制指令碼

同時在 IIS 的 “Web 服務擴充”裡多了 FastCGI Handler。

 
2.下載 PHP5.2.14 Windows 版

http://www.php.net/downloads.php

下載 .zip 格式的版本,下載後解壓至 c:\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=C:\PHP\php-5.2.14-Win32\php-cgi.exe

“php”表示副檔名,“PHP”是配置節名稱,以“[PHP]”定義。

4. 配置 php.ini

將 C:\PHP\php-5.2.14-Win32\php.ini-recommended 複製一個,然後重新命名為 D:\PHP\php.ini

開啟 C:\PHP\php-5.2.14-Win32\php.ini,修改:

extension_dir = "C:\PHP\php-5.2.14-Win32\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。

參考  http://hi.baidu.com/imdao/blog/item/16583512f11cb654f819b858.html

          Configure the FastCGI Extension for IIS 6.0

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.