Apache2與Tomcat5整合

回覆文章
布魯斯
Site Admin
文章: 211
註冊時間: 週四 2月 16, 2006 3:34 pm

Apache2與Tomcat5整合

文章 布魯斯 »

Apache2與Tomcat5整合
安裝 J2SDK

下載位置:
先下載j2sdk-1_4_1_02-linux-i586.bin

[root@localhost linux]# chmod a+x j2sdk-1_4_1_02-linux-i586.bin
[root@localhost linux]# ./j2sdk-1_4_1_02-linux-i586.bin
[root@localhost local]# mv /home/bruce/linux/j2sdk1.4.1_02 /usr/local/j2sdk1.4.1_02


安裝 tomcat5
http://cvs.apache.org/builds/jakarta-tomcat-5/nightly/
Mirror下載位置:http://ftp.nsysu.edu.tw/Unix/Web/apache/jakarta/tomcat-5/v5.0.18/bin/
http://ftp.nsysu.edu.tw/Unix/Web/apache ... .18.tar.gz

[root@localhost linux]# tar -zxvf jakarta-tomcat-5.0.18.tar.gz
[root@localhost linux]# mv /home/bruce/linux/jakarta-tomcat-5.0.18 /usr/local/jakarta-tomcat-5.0.18
[root@localhost linux]# cd /usr/local/
[root@localhost local]# ln -s jakarta-tomcat-5.0.18/ tomcat

將 Java 及 tomcat 的相關路徑加到環境變數,請編輯 /etc/profile,在檔案最下方加入:
PATH=$PATH:/usr/local/j2sdk1.4.1_02/bin
export JAVA_HOME=/usr/local/j2sdk1.4.1_02
export CLASSPATH=$JAVA_HOME/lib
export CATALINA_HOME=/usr/local/tomcat

[root@localhost local]# vi /etc/profile
[root@localhost local]# $CATALINA_HOME/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/local/j2sdk1.4.1_02
[root@localhost local]#

將 tomcat 整合到 apache

下載mod_jk2
下載位置:http://ftp.cis.nctu.edu.tw/data/apache/jakarta/tomcat-connectors/jk2/source/
http://ftp.cis.nctu.edu.tw/data/apache/ ... src.tar.gz

編譯Jakarta-Tomcat-connectors 2

[root@localhost tmp]# tar -zxvf /home/bruce/linux/jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
[root@localhost tmp]# cd jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2/
[root@localhost native2]# chmod a+x buildconf.sh
[root@localhost native2]# ./buildconf.sh
[root@localhost native2]# ./configure --with-apxs2=/usr/local/apache2/bin/apxs
[root@localhost native2]# make
[root@localhost native2]# cp /tmp/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/build/jk2/apache2/.libs/mod_jk2.so /usr/local/apache2/modules/mod_jk2.so
[root@localhost native2]# cp /tmp/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/conf/workers2.properties /usr/local/apache2/conf/workers2.properties


編輯 httpd.conf
尋找DSO
加入LoadModule jk2_module modules/mod_jk2.so

編輯 workers2.properties
修改最下面的example及servlets


[uri:/jsp-examples/*]
info=JSP examples, map requests for all JSP pages to Tomcat.
context=/jsp-examples

[uri:/servlets-examples/*]
info=Servlet examples, map requests for all servlets to Tomcat.
context=/servlets-examples


重新啟動tomcat及apache即完成整合
回覆文章