Topic: [fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) |
Print this page |
1.[fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) | Copy to clipboard |
Posted by: micnet Posted on: 2003-03-25 13:11 本文介绍的配置方法,用JK2连接Apache和Tomcat,连接使用JNI通道。并且启动Apache时,Apache会通过JNI直接在后台启动Tomcat,无须你再手工启动Tomcat。 我是参考Apache网站的资料,并在自己Win2K上配置成功。配置过程如下,希望对大家有用。 安装版本: Apache 2.0.44 Tomcat 4.1.18 mod_jk2-2.0.43.dll 以上版本都可在WWW.APACHE.ORG下载 整合步骤 首先假定Apache2和Tomcat4已经安装完成,安装目录分别为:[Apache_install_dir]和[Tomcat_install_dir]。并且Apache的服务端口为80,Tomcat服务端口为8080。 一:在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 二:配置Apache端 Apache端通过workers2.properties文件使用JK2。 在[Apache_install_dir]/conf目录中新建文件workers2.properties。(注意不要误建成workers2.properties.txt) 编辑该文件,添加如下内容: # 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/bootstrap.jar;[Tomcat_install_dir]/bin/commons-daemon.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=${serverRoot}/logs/stdout.log stderr=${serverRoot}/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 注意:其中[Tomcat_install_dir]用你实际安装路径代替,[uri:/examples/*]用于映射Tomcat的examples Webapp,为了后面测试用。 三:配置Tomcat端 Tomcat端通过jk2.properties文件使用JK2。 在[Tomcat_install_dir]/conf目录中已经有jk2.properties文件,用如下内容覆盖原内容: # Set the desired handler list handler.list=apr,request,container,channelJni # Enable jni use channelJni directive apr.jniModeSo=D:\Apache Group\Apache2\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 四:测试 以上配置完毕后,整合就成功了。启动Apache。(不必手工启动Tomcat,Apache会自动在后台启动Tomcat,Tomcat的屏幕输出被重新定向到[Apache_install_dir]/logs/stdout.log和stderr.log中。 打开浏览器,访问 http://localhost/examples/ 哈哈!成功了没有? |
2.Re:[fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) [Re: micnet] | Copy to clipboard |
Posted by: flytiger Posted on: 2003-03-27 03:39 I need to add something to this article, first. You need also configure the shared memory handling file (shm file) to make this working. in workers2.properties add follow lines # Shared memory handling. Needs to be set. [shm] file=${serverRoot}/logs/shm.file size=1048576 in jk2.properties you don't need the following lines
because you have
at the end of jk2.properties, this will override the previous config in the same file. just simply remove one of these lines. Have fun. |
3.Re:[fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) [Re: micnet] | Copy to clipboard |
Posted by: why Posted on: 2003-12-17 20:54 I got this error: Apache2\log2\error.log: [Wed Dec 17 08:46:06 2003] [error] Can't find class org/apache/jk/apr/AprImpl If I start Tomcat manually, I got 17-Dec-2003 8:50:44 AM org.apache.jk.server.JkMain start INFO: APR not loaded, disabling jni components: java.io.IOException: java.lang.UnsatisfiedLinkError: no jkjni in java.library.path any clue? BTW, I added [Tomcat_install_dir]/server/lib/commons-logging.jar to OPT=-Djava.class.path |
4.Re:[fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) [Re: micnet] | Copy to clipboard |
Posted by: why Posted on: 2003-12-18 09:08 4.1.18 seems to work with Apache/JK2-JNI until I put log4j into Tomcat/common/lib... |
5.Re:[fwd] Apache2.0.44和Tomcat4.1.18通过JK2整合(使用JNI通道) [Re: micnet] | Copy to clipboard |
Posted by: collins Posted on: 2003-12-19 09:59 楼主的方法行不通,需要修改这一行: OPT=-Djava.class.path=[Tomcat_install_dir]/bin/tomcat-jni.jar;[Tomcat_install_dir]/bin/bootstrap.jar;[Tomcat_install_dir]/bin/commons-daemon.jar 增加mx4j.jar,不然无法启动。 连接成功后,http://localhost:8080/examples/能打开实例页面,然而,一些例子运行会出现错误,说什么可能是JAVA_HOME的版本与JDK版本不对。察看注册表,原因可能是这样的,apache会自动找jre注册表中的版本,我装了JDK1.4,然后装了JB9,JB9的JDK是1.4.1。修改了半天把注册表,让PACHE适用1.4.2,与JAVA_HOME相同,但问题依旧。 没辙,很晚了,就放下了,哪位成功过? |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |