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

Windows 環境 Apache 2.2 安裝與虛擬目錄配置快速參考指南

編輯:關於伺服器

下載與安裝

  • 官網:httpd.apache.org。
  • 選擇:httpd-2.2.x-win32-x86-no_ssl.msi (無 SSL) 或 openssl 版。
  • 安裝建議:**All Users, Port 80, as a Service** 自動註冊系統服務。
  • 若 80 埠被佔用 (IIS),安裝後修改 httpd.conf:Listen 81 並重裝。

驗證安裝

瀏覽器訪問 https://localhost (或 :81) 出現 "It works!" 頁面即成功。

核心配置 (httpd.conf)

# 文檔根目錄
DocumentRoot "D:/Programs/Apache2.2/htdocs"

# 虛擬目錄 (別名)
Alias /webpath/ "D:/Programs/WebPath"
Alias /webpath "D:/Programs/WebPath"  # 無尾斜線也能訪問,Apache 自動補全

# URL 永久重導向
Redirect permanent /foo/ https://www.example.com/bar/

# 虛擬主機配置參考官方文檔
# https://httpd.apache.org/docs/2.2/vhosts/

配置檢查與日誌

  • 開始功能表 → Apache → Test Configuration** 驗證語法。
  • 錯誤查看:[Apache安裝目錄]/logs/error.log。

安全建議

建立專用低權限服務帳號運行 Apache,而非預設 Local System。

Copyright © Windows教程網 All Rights Reserved