Windows 7 x64 普及後,開發者常需在本機建立 64 位元 Apache 環境。官方 Apache 僅提供 32 位元 Windows 版本,但社群高手已編譯可用的 64 位元二進制檔。本文記錄在 Windows 7 x64 上部署 Apache 2.2 64-bit 的完整步驟與避坑指南。
httpd-2.2.13-win64.rar(來自 blackdot.be,Visual Studio 2005 編譯)D:/Web/Tool/httpd-2.2-x64# 訪問 Blackdot.be :: Apache 64-bit Binaries
# 下載 httpd-2.2.13-win64.rar
# 解壓縮至 D:/Web/Tool/httpd-2.2-x64
開始 → 搜尋 cmd → 右鍵「以系統管理員身分執行」
cd /d D:\Web\Tool\httpd-2.2-x64\bin
httpd -k install
預期輸出:
Installing the Apache2.2 service
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd: Syntax error on line 35 of D:/Web/Tool/httpd-2.2-x64/conf/httpd.conf:
ServerRoot must be a valid directory
關鍵點:「successfully installed」表示服務註冊成功,但 httpd.conf 設定錯誤(ServerRoot 路徑錯誤)導致無法啟動。先忽略錯誤,手動修正設定檔再啟動。
用編輯器開啟 D:\Web\Tool\httpd-2.2-x64\conf\httpd.conf,修改:
# 原本錯誤路徑
# ServerRoot "D:/Web/Tool/httpd-2.2-x64"
# 修正為實際解壓縮路徑(確認 bin、conf 資料夾存在)
ServerRoot "D:/Web/Tool/httpd-2.2-x64"
# 其他建議同步檢查:
# Listen 80
# DocumentRoot "D:/Web/Tool/httpd-2.2-x64/htdocs"
# Directory 設定指向正確 DocumentRoot
httpd -k start
無錯誤訊息即表示啟動成功。瀏覽器訪問 https://localhost 應顯示 "It works!" 頁面。
httpd.conf,再執行 httpd -k install 與 httpd -k start,避免服務註冊後仍無法啟動。httpd.conf 載入 php5apache2_2.dll 並設定 PHPIniDir。httpd -k stop 停止、httpd -k restart 重啟、httpd -k uninstall 移除服務。掌握此流程,即可在 Windows 7 x64 快速建立生產級相容的 Apache 64-bit 開發測試環境。
Windows 7 提示「系統資源不足」六大成因與對應解決方案
Windows 7 ISO 版本轉換器:一鍵將旗艦版轉為專業版,省去重新下載
Win7 電源管理深度解析:全新電池方案、自訂計畫與行動中心
Windows 7 修改「我的文件」等使用者資料夾預設儲存位置
Windows 7 工作管理器看不到選單列/標題列?雙擊邊框一秒恢復
Windows 7 裝置中心 (Windows Mobile Device Center) 功能詳解:取代 ActiveSync、同步郵件/行事曆/聯絡人/媒體/檔案瀏覽
Win7 安裝 Adobe Flash Player 提示「權限不足」?以管理員身分執行 / 啟用內建 Administrator 帳號雙解