Apache + Tomcat with mod_jk.so

| | Comments (0)

安裝 Tomcat
wget http://archive.apache.org/dist/jakarta/tomcat-5/v5.5.11/bin/jakarta-tomcat-5.5.11.tar.gz
tar zxf jakarta-tomcat-5.5.11.tar.gz -C /usr/local
mv /usr/local/jakarta-tomcat-5.5.11 /usr/local/tomcat
下載 JDK 5.0 http://java.sun.com/j2se/1.5.0/download.jsp
chmod +x jdk-1_5_0_04-linux-i586.bin
mv jdk1.5.0_04 /usr/local/java
解開後放到 /usr/local/java
編輯一個 script for tomcat (/usr/local/bin/tomcat.sh)
export JAVA_HOME=/usr/local/java
export CATALINA_HOME=/usr/local/tomcat
case $1 in
啟動 tomcat 用 tomcat.sh start, 關閉用 tomcat.sh stop
註: 在啟動 tomcat 前, JAVA_HOME, CATALINA_HOME 變數是必要的

編譯 mod_jk.so
wget http://archive.apache.org/dist/jakarta/tomcat-5/v5.5.11/src/jakarta-tomcat-5.5.11-src.tar.gz
tar zxf jakarta-tomcat-5.5.11-src.tar.gz
cd jakarta-tomcat-5.5.11-src/jakarta-tomcat-connectors/jk/native
./configure --with-apxs=/usr/local/apache/bin/apxs
cp apache-1.3/mod_jk.so /usr/local/apache/libexec
註: 加 mod_jk.so 的用意就是可以用 JkMount 把 webapps 下的目錄 mount 到 DocumentRoot, 使可以不用打 :8080

設定 Apache
在 httpd.conf 加入
LoadModule jk_module libexec/mod_jk.so
AddModule mod_jk.c
JkWorkersFile conf/mod_jk.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
# 指定那些檔案、目錄要用 Tomcat 去跑
JkMount /*.jsp ajp13
JKMount /jsp-examples/* ajp13
註: apache 在編譯時, configure 需加入 --enable-module=so 參數
在 apache conf 目錄下建編立 mod_jk.properties, 內容如下
註: ajp13 指 Apache JServ Protocol version 1.3

啟動 tomcat, 重新啟動 apache, 連連看
http://[your host]/index.jsp
http://[your host]/jsp-examples/
若有看到網頁, jsp 範例程式也正常, 大功告成!

Leave a comment

March 2009

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

About this Entry

This page contains a single entry by Pank published on August 25, 2005 7:25 PM.

Extract files from RPM file was the previous entry in this blog.

compare - Fast binary comparison of two files is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.