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

Windows 下整合 Tomcat 與 Apache 建置高效能 Web 平台

編輯:Windows XP 系統介紹

安裝 Apache HTTP Server

  1. 執行 apache_2.0.63-win32-x86-no_ssl.msi,採預設值安裝。
  2. 安裝完成會自動註冊「Apache HTTP Service」系統服務。
  3. 確認 httpd.conf 中 Listen 80,且 80 埠未被佔用。
  4. 透過「開始」→「程式集」→「Apache HTTP Server 2.0」→「Control Apache Server」管理啟動/重啟/停止。

加入 JK Connector (mod_jk.so)

將 mod_jk.so 複製至 Apache modules 目錄。

建立 workers.properties 設定 Tomcat 背景工作程序

路徑:Apache 根目錄/conf/workers.properties

worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1

若有多台 Tomcat,可在 worker.list 以逗號分隔,並分別設定 port/host。

修改 httpd.conf 載入 JK 模組與日誌

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /*.jsp worker1
JkMount /helloapp/* worker1

驗證整合成功

  1. 重啟 Tomcat 與 Apache。
  2. 瀏覽 https://localhost/index.jsp 應顯示 Tomcat 預設首頁。
  3. 部署測試應用 helloapp 後,存取 https://localhost/helloapp/hello.htm 驗證 JSP/Servlet 運作。

若失敗,請檢查 logs/mod_jk.log 診斷錯誤原因。

Copyright © Windows教程網 All Rights Reserved