[Software] Tomcat + Mod_Jk + JDBC

這已經是舊的文章了,不過怕自已忘記,還是貼出來整理一下。
1.在 linux 下裝好 apache 1.3
2.在 linux 下裝好 j2sdk
3.抓取 tomcat 4 的編譯完成後的壓縮檔
from: http://apache.cdpa.nsysu.edu.tw/jakarta/tomcat-4/v4.1.30/bin/jakarta-tomcat-4.1.30.tar.gz
4.抓取 mod_jk 的 source code 準備回來編譯
from: http://apache.cdpa.nsysu.edu.tw/jakarta/tomcat-connectors/jk/jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz

5.安裝 apache-dev 套件.用rpm or dpkg 裝即可

6.#cd jakarta-tomcat-connectors-jk-1.2.5-src/jk/native/
先確定apxs 的執行檔在哪 ..用 whereis apxs
#./configure –with-apxs=/usr/bin/apxs
#cd apache-1.3
#cp mod_jk.so.0.0.0 /usr/lib/apache/1.3/mod_jk.so
然後在 /etc/apache/modules.conf 加一行 LoadModule jk_module /usr/lib/apache/1.3/mod_jk.so 來讓 apache 載入 mod_jk
7.抓取mysql 的 jdbc driver,目前我用 3.0 stable 板本
from: http://www.mysql.com/downloads/api-jdbc-stable.html

  1. 然後在 /etc/apache/workers.properties,底下目錄該改的要改哦

-------------------------------------------

# Define some properties
workers.apache_log=/var/log/apache/
workers.tomcat_home=/opt/tomcat-4.1
workers.java_home=/opt/j2sdk1.4/
ps=/
worker.list=worker1
# Set properties for worker2 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

-------------------------------------------

9.在 httpd.conf 加上下面的內容,當然目錄該改的還是要改
---------------------------------------------

# Where to find workers.properties
JkWorkersFile /etc/apache/workers.properties
# Where to put jk logs
JkLogFile /var/log/apache/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat “%w %V %T”

# Static files in the examples webapp are served by apache
Alias /examples /opt/tomcat-4.1/webapps/examples

# The following line prohibits users from directly access WEB-INF

AllowOverride None
deny from all

# All JSP will goes to worker1
JkMount /.jsp worker1
# All servlets goes to worker1
JkMount /
/servlet/ worker1

--------------------------------------------

10.在tomcat4.1/bin/
裡面在 104 行的地方加上 CLASSPATH="$CLASSPATH”:/opt/mysql-connector-bin.jar 其中的 /opt/mysql-connector-bin.jar 視你的mysql-connector 放在哪個目錄下,記得要打完整路徑哦。

11.最後 http://網址/example/jsp 就可以看到範例了

ps. 如果有裝 gij 套件的話,請先移除,要不然會出問題