Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 7 x64 安裝 Apache 64-bit 完整教學:從下載到啟動服務

編輯:Windows 7 系統介紹

Windows 7 x64 普及後,開發者常需在本機建立 64 位元 Apache 環境。官方 Apache 僅提供 32 位元 Windows 版本,但社群高手已編譯可用的 64 位元二進制檔。本文記錄在 Windows 7 x64 上部署 Apache 2.2 64-bit 的完整步驟與避坑指南。

環境與資源

  • 作業系統:Windows 7 x64
  • Apache 來源:httpd-2.2.13-win64.rar(來自 blackdot.be,Visual Studio 2005 編譯)
  • 安裝路徑範例:D:/Web/Tool/httpd-2.2-x64

詳細安裝步驟

1. 下載並解壓縮

# 訪問 Blackdot.be :: Apache 64-bit Binaries
# 下載 httpd-2.2.13-win64.rar
# 解壓縮至 D:/Web/Tool/httpd-2.2-x64

2. 以管理員身分開啟命令提示字元

開始 → 搜尋 cmd → 右鍵「以系統管理員身分執行」

cd /d D:\Web\Tool\httpd-2.2-x64\bin

3. 安裝為 Windows 服務

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 路徑錯誤)導致無法啟動。先忽略錯誤,手動修正設定檔再啟動。

4. 修正 httpd.conf 關鍵設定

用編輯器開啟 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

5. 啟動服務並驗證

httpd -k start

無錯誤訊息即表示啟動成功。瀏覽器訪問 https://localhost 應顯示 "It works!" 頁面。

進階建議與常見問題

  • 優先修改設定再安裝: 解壓縮後先改好 httpd.conf,再執行 httpd -k install 與 httpd -k start,避免服務註冊後仍無法啟動。
  • 防火牆規則: 需在 Windows 防火牆新增輸入規則允許 TCP 80 連接埠(或 Apache 執行檔)。
  • PHP 整合: 需下載 VC9 編譯的 PHP 64-bit (Non Thread Safe),在 httpd.conf 載入 php5apache2_2.dll 並設定 PHPIniDir。
  • 服務管理: httpd -k stop 停止、httpd -k restart 重啟、httpd -k uninstall 移除服務。

為什麼選擇 64-bit Apache?

  • 突破 32-bit 程序 2/4 GB 記憶體限制,適合高併發、大記憶體應用
  • 與 64-bit PHP、資料庫驅動完美搭配,效能更佳
  • 現代 Windows Server/開發環境主流趨勢

掌握此流程,即可在 Windows 7 x64 快速建立生產級相容的 Apache 64-bit 開發測試環境。

Copyright © Windows教程網 All Rights Reserved