Windows 7 內建 IIS 7.5 (Internet Information Services),提供 ASP.NET、PHP、靜態內容託管能力,適合開發測試、內部系統部署、原型展示。本文涵蓋功能啟用、網站建立、應用程式集區配置、防火牆規則、網域綁定、SSL 憑證與遠端管理完整流程。
Internet Information Services
├── Web 管理工具
│ ├── IIS 管理主控台
│ ├── IIS 管理指令碼和工具
│ └── IIS 管理服務 (遠端管理需勾選)
├── 全域應用程式開發
│ ├── .NET 延伸模組
│ ├── ASP.NET
│ ├── CGI
│ ├── ISAPI 延伸模組
│ └── ISAPI 篩選器
├── 一般 HTTP 功能
│ ├── 預設文件
│ ├── 目錄瀏覽
│ ├── HTTP 錯誤
│ ├── 靜態內容
│ └── HTTP 重新導向
├── 效能
│ ├── 靜態內容壓縮
│ └── 動態內容壓縮
└── 安全性
├── 要求篩選
├── Windows 驗證
└── URL 授權
# 管理員 CMD/PowerShell
dism /online /enable-feature /featurename:IIS-WebServerRole /all
dism /online /enable-feature /featurename:IIS-WebServer /all
dism /online /enable-feature /featurename:IIS-CommonHttpFeatures /all
dism /online /enable-feature /featurename:IIS-ApplicationDevelopment /all
dism /online /enable-feature /featurename:IIS-ASPNET /all
dism /online /enable-feature /featurename:IIS-NetFxExtensibility /all
dism /online /enable-feature /featurename:IIS-ManagementConsole /all
dism /online /enable-feature /featurename:IIS-ManagementService /all
dism /online /enable-feature /featurename:IIS-BasicAuthentication /all
dism /online /enable-feature /featurename:IIS-WindowsAuthentication /all
dism /online /enable-feature /featurename:IIS-RequestFiltering /all
dism /online /enable-feature /featurename:IIS-HttpCompressionStatic /all
dism /online /enable-feature /featurename:IIS-HttpCompressionDynamic /all
https://localhost/ 或 https://127.0.0.1/%systemdrive%\inetpub\wwwroot (通常 C:\inetpub\wwwroot)
# 範例:建立專案目錄
mkdir C:\WebSites\MyProject
# 放入 index.html、web.config、應用程式碼
inetmgr → EnterMyProjectC:\WebSites\MyProject80 (或 8080 避開衝突)myproject.local (配合 hosts 檔案)v4.0 (ASP.NET Core 需 無管理代碼 + ANC模組)ApplicationPoolIdentity (虛擬帳號,安全隔離)C:\PHPphp.ini-production 為 php.ini,調整:
extension_dir = "C:\PHP\ext"
cgi.force_redirect = 0
cgi.fix_pathinfo = 1
fastcgi.impersonate = 1
date.timezone = "Asia/Taipei"
; 啟用常用擴充
extension=curl
extension=gd
extension=mbstring
extension=mysqli
extension=pdo_mysql
extension=openssl
*.phpFastCgiModuleC:\PHP\php-cgi.exePHP_via_FastCGIC:\PHP\php-cgi.exe → 監視檔案變更、執行個體上限 10
netsh advfirewall firewall add rule name="IIS HTTP" dir=in action=allow protocol=TCP localport=80 profile=domain,private,public
netsh advfirewall firewall add rule name="IIS HTTPS" dir=in action=allow protocol=TCP localport=443 profile=domain,private,public
# 編輯 hosts 檔案 (管理員權限)
notepad %windir%\system32\drivers\etc\hosts
# 新增行
127.0.0.1 myproject.local
192.168.1.100 myproject.local # 區域網其他電腦用此 IP
區域網其他電腦同樣修改 hosts 或架設內部 DNS 解析 myproject.local → 192.168.1.100。
www.example.comWMSvc (Web Management Service) → 啟動類型:自動 → 啟動| 現象 | 檢查項目 | 解決 |
|---|---|---|
| HTTP 403.14 禁止目錄瀏覽 | 無預設文件、目錄瀏覽未啟用 | 啟用目錄瀏覽或確保 Default Document 含 index.html/php |
| HTTP 500.19 內部錯誤 | web.config 格式錯誤/權限/模組缺失 | 詳細錯誤頁面查看錯誤碼 (0x8007000d 等)、安裝缺失模組 |
| HTTP 503 服務不可用 | 應用程式集區已停止 | 檢查事件檢視器 → System/Application、啟用集區、修正程式碼錯誤 |
| 靜態檔案 404 | 靜態內容模組未安裝/處理常式缺失 | 啟用 IIS-StaticContent、檢查處理常式對應 |
| 區域網無法存取 | 防火牆/ICS/網路隔離/繫結 IP 錯誤 | 防火牆規則、IIS 繫結設為 All Unassigned 或具體內網 IP |
Windows 7 IIS 7.5 雖非最新版,但架構成熟、文檔豐富、相容性佳。掌握「功能啟用 → 網站建立 → 應用程式集區隔離 → 防火牆開放 → 網域綁定 → 遠端管理」標準化流程,可快速交付穩定的 Web 託管環境。生產負載建議遷移至 Windows Server 2019/2022 + IIS 10.0 或 Linux + Nginx。