Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Windows Server IIS + PHP + MySQL + Zend Optimizer 完整部署指南 (2006 經典版)

編輯:關於伺服器

本文記錄 Windows 2000/2003/XP 環境下 IIS、PHP 4.4.0/5.1.2、MySQL 4.0.26/4.1.16/5.0.18、Zend Optimizer 2.6.2、GD 庫、phpMyAdmin 2.8.0.3 的完整安裝配置流程。雖版本較早,但配置邏輯對理解 PHP ISAPI 模式部署仍有參考價值。

軟件獲取與版本規劃

  • PHP:推薦 ZIP 解壓版。PHP 4.4.0 / 5.1.2 官方鏡像下載
  • MySQL:PHP 4 配合 4.0.26;PHP 5 可用 4.1.16 或 5.0.18
  • Zend Optimizer:2.6.2 版(需註冊賬號,文中提供共享賬號)
  • phpMyAdmin:2.8.0.3 Windows 版

目錄結構規劃

為便於備份遷移,建議將所有 PHP 相關軟件安裝至非系統盤(如 D:\php\):

  • D:\php\php4\ - PHP 4.4.0 解壓目錄
  • D:\php\php5\ - PHP 5.1.2 解壓目錄
  • D:\php\tmp\ - 上傳/Session 臨時目錄(需讀寫權限)

PHP 核心配置 (php.ini)

  1. 複製 php.ini-dist 為 php.ini 至系統目錄(C:\Windows 或 C:\WINNT)
  2. 關鍵參數調整:
    • register_globals = On(兼容舊代碼,生產環境建議 Off)
    • extension_dir = "D:/php/php4/extensions/" (PHP 5: D:/php/php5/ext/)
    • upload_tmp_dir = D:/php/tmp(取消註釋,指定臨時目錄)
    • session.save_path = D:/php/tmp(取消註釋)
    • 啟用常用擴展(去掉前綴 ;):
      • 必選:php_gd2.dll (GD庫)、php_mbstring.dll、php_mysql.dll
      • 可選:php_curl.dll、php_ldap.dll、php_zip.dll 等
    • 性能/上傳調優:
      max_execution_time = 300
      max_input_time = 600
      memory_limit = 64M
      upload_max_filesize = 20M

IIS 整合 PHP (ISAPI 模式)

  1. 確認 IIS 已安裝並運行(WWW 服務、IIS Admin 服務啟動)
  2. IIS 管理器 → 網站屬性 → ISAPI 篩選器 → 添加:
    • 篩選器名稱:PHP
    • 可執行文件:D:\php\php4\sapi\php4isapi.dll (PHP 5: D:\php\php5\php5isapi.dll)
  3. 主目錄 → 配置 → 應用程序映射 → 添加:
    • 可執行文件:同上 php4isapi.dll/php5isapi.dll
    • 擴展名:.php (可追加 .php3 .phtml .php5 等)
    • 動作:GET,HEAD,POST,TRACE
    • 勾選「腳本引擎」、「確認文件是否存在」
  4. 文檔標籤 → 添加默認文檔 index.php 並置頂
  5. 主目錄執行權限選「純腳本」
  6. IIS 6.0 (Win2003) 額外操作:Web 服務擴展 → 允許「ISAPI 擴展」、「Active Server Pages」
  7. 重啟 IIS:net stop w3svc && net stop iisadmin && net start w3svc

驗證測試

Web 根目錄創建 php.php:

<?php phpinfo(); ?>

瀏覽器訪問 https://localhost/php.php,確認 Server API 顯示 ISAPI,GD、MySQL、Zend Optimizer 等擴展載入正常。

MySQL 與 phpMyAdmin 部署要點

  • MySQL 安裝向導按提示完成,設置 root 密碼
  • Zend Optimizer 安裝向導指定 php.ini 路徑自動配置
  • phpMyAdmin 解壓至 Web 目錄(如 phpmyadmin),配置 config.inc.php 設置 $cfg['Servers'][$i]['host'] = 'localhost'、認證模式 cookie 或 config
註:本文基於 2006 年技術環境。現代生產環境強烈建議使用 PHP 8.x、MySQL 8.0、PHP-FPM (FastCGI) 替代 ISAPI、IIS 10+、啟用 HTTPS、配置 OpenSSL、使用 Composer 管理依賴。
Copyright © Windows教程網 All Rights Reserved