Apache2.0.47與Tomcat4.1.27整合過(guò)程
發(fā)表時(shí)間:2023-08-20 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]參考了網(wǎng)上很多資料,發(fā)現(xiàn)大都或多或少有些小問(wèn)題,現(xiàn)把我的整合過(guò)程貼出來(lái),供大家參考。一、準(zhǔn)備需要以下程序:j2sdk1.4.2_01,apache-2.0.47,jakarta-tomcat-4.1...
參考了網(wǎng)上很多資料,發(fā)現(xiàn)大都或多或少有些小問(wèn)題,現(xiàn)把我的整合過(guò)程貼出來(lái),供大家參考。
一、準(zhǔn)備
需要以下程序:
j2sdk1.4.2_01,apache-2.0.47,jakarta-tomcat-4.1.27,以及mod_jk2-2.0.43.dll
以上程序都可以在sun和apache.org下載到。
j2sdk1.4.2_01 : http://java.sun.com/j2se/1.4.2/download.html選J2SE v 1.4.2_01 的SDK
apache-2.0.47 : http://apache.linuxforum.net/dist/httpd/binaries/win32/apache_2.0.47-win32-x86-no_ssl.exe
tomcat-4.1.27 : http://apache.linuxforum.net/dist/jakarta/tomcat-4/binaries/jakarta-tomcat-4.1.27.exe
mod_jk2-2.0.43.dll : http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/release/v2.0.2/bin/win32/mod_jk2-2.0.43.dll
注意下載的jk2文件名:mod_jk2-2.0.43.dll,而網(wǎng)上還有mod_jk-2.0.4x.dll,這是jk而不是jk2
二、安裝
假設(shè)j2sdk1.4.2_01安裝到D:\j2sdk1.4.2_01下,用[Java_install_dir]代表此路徑
apache-2.0.47安裝到D:\Program Files\Apache Group\Apache2,用[Apache_install_dir]代表此路徑,服務(wù)端口為80
jakarta-tomcat-4.1.27安裝到D:\Program Files\Apache Group\Tomcat 4.1,用[Tomcat_install_dir]代表此路徑,服務(wù)端口為8080
在系統(tǒng)環(huán)境變量里添加JAVA_HOME和TOMCAT_HOME分別為以上路徑,再修改CLASS_PATH,添加%JAVA_HOME%\lib;%TOMCAT_HOME%\bin;
安裝時(shí)把Apache和Tomcat都設(shè)置為后臺(tái)服務(wù)方式運(yùn)行。
三、配置
1. 在Apache2中安裝mod_jk2-2.0.43.dll
將mod_jk2-2.0.43.dll拷貝到[Apache_install_dir]/modules目錄中
編輯[Apache_install_dir]/conf/httpd.conf配置文件,在文件最后添加如下一行:
LoadModule jk2_module modules/mod_jk2-2.0.43.dll
2. 配置Apache端
[在Apache_install_dir]/conf目錄中新建文件workers2.properties,內(nèi)容如下:
# Define the comunication channel
[channel.jni:jni]
info=The jni channel, used if tomcat is started inprocess
# Define the parameters for the Java Virtual Machine
[vm:]
info=Parameters used to load a JVM in the server process
OPT=-Djava.class.path=[Tomcat_install_dir]\bin\tomcat-jni.jar;[Tomcat_install_dir]\bin\tomcat.jar
OPT=-Dtomcat.home=[Tomcat_install_dir]
OPT=-Dcatalina.home=[Tomcat_install_dir]
OPT=-Xmx128M
# JNI worker startup handler
[worker.jni:onStartup]
info=Command to be executed by the VM on startup. This one will start tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=start
stdout=[Apache_install_dir]\logs\stdout.log
stderr=[Apache_install_dir]\logs\stderr.log
# JNI worker shutdown handler
[worker.jni:onShutdown]
info=Command to be executed by the VM on shutdown. This one will stop tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=stop
# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
info=Map the whole webapp
#注:
#網(wǎng)上有資料OPT=-Djava.class.path是指向\lib\,實(shí)際上安裝目錄下并無(wú)\lib目錄,如不修改會(huì)出現(xiàn)java.lang.NoClassDefFoundError: org/apache/jk/apr/TomcatStarter異常
#把[Tomcat_install_dir]和[Apache_install_dir]換成實(shí)際安裝路徑,其余不用做任何改動(dòng)
3. 配置Tomcat端
修改[Tomcat_install_dir]/conf/jk2.properties,用以下內(nèi)容替換原來(lái)內(nèi)容:
# Set the desired handler list
handler.list=apr,request,container,channelJni
# Enable jni use channelJni directive
apr.jniModeSo=[Apache_install_dir]\modules\mod_jk2-2.0.43.dll
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
# If you wish to start the Tomcat from inside web server then
# you don′t need any above directive. Here is shown the default
# value for the apr that you can ommit
apr.jniModeSo=inprocess
#注:
#把[Tomcat_install_dir]和[Apache_install_dir]換成實(shí)際安裝路徑,其余不用做任何改動(dòng)
#這種方式使用JNI通道,因此運(yùn)行Apache時(shí)會(huì)通過(guò)JNI直接在后臺(tái)啟動(dòng)Tomcat。
四、測(cè)試:
啟動(dòng)Apache
看http://localhost/examples/jsp/
如顯示正確內(nèi)容則整合成功!
如不成功請(qǐng)檢查[Apache_install_dir]\logs\stdout.log和[Apache_install_dir]\logs\stderr.log日志,看是什么錯(cuò)誤,根據(jù)錯(cuò)誤提示進(jìn)行修改。