Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 技术文章库  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程
zzhangwa





发贴: 3
积分: 0
于 2003-05-06 19:49 user profilesend a private message to usersend email to zzhangwasearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
假设系统中已经安装了jdk
用JK2连接Apache和Tomcat,连接使用JNI通道。并且启动Apache时,Apache会通过JNI直接在后台启动Tomcat,无须你再手工启动Tomcat。
安装版本:
Apache 2.0.43
Tomcat 4.1.24
mod_jk2-2.0.43.dll
(1)安装软件
a、  安装Apache2.0.43
按照安装向导进行安装(选择安装目录为d:\,方便下面操作;安装成功后其路径为:d:\Apache2)
b、   安装Tomcat4.1.24
按照安装向导进行安装(更改安装目录为C:\Tomcat4,方便下面操作),其间会要你输入Admin(系统管理员)的口令。
c、  首次配置及测试:对以上安装的软件环境进行首次配置,并测试其环境。
(1)配置--环境变量:
1.新建系统变量JAVA_HOME,其值为:C:\j2sdk1.4.1 //若你没按以上路径安装请更改为正确的路径
2.新建系统变量TOMCAT_HOME,其值为:C:\Tomcat4 //同上
3.新建系统变量CLASSPATH,其值为:%JAVA_HOME%\lib;%TOMCAT_HOME%\lib
(2)修改错误:
1.Apache2.0.43有一个小问题,默认安装成功后在Apache2主目录下的htdocs目录中没有index.html文件,你须将该目录下的index.html.en改名为index.html
(3)测试默认服务:
请先运行Apache2与Tomcat4.
1.打开浏览器,在地址栏中输入:http://localhost 检验:此时能在浏览器中看到Apache2的欢迎界面.说明Apache2工作正常.(注意,Apache默认端口为80,
若有其它程序占用,请更改,下面有说明)
2.打开浏览器,在地址栏中输入:http://localhost:8080 检验:此时能在浏览器中看到Tomcat的欢迎界面.说明Tomcat工作正常.(注意,Tomcat默认端口为
8080,若有其它程序占用,请更改,下面有说明)
小结:若到此步骤没有任何错误,那可继续下面的操作.

(4)测试你的项目:
现只用Tomcat测试你的项目,为方便此例说明,假设你已有一个项目在E:\Application\OA目录下
(包含index.jsp及其它jsp文件和bean,如WEB-INF\classes\下的servlet、javabean)。
1.设置Tomcat以支持你的项目,打开C:\Tomcat4\conf\server.xml文件,在""之前,""之后添加<Context path="/oa " docBase="E:\Application\OA" debug="0"/>
并保存。
说明:Context (表示一个web应用程序): docBase定义应用程序的路径;path 表示此web应用程序的url的前缀,这样请求的url为http://localhost:8080/oa;
reloadable 这个属性非常重要,如果为true,则tomcat会自动检测应用程序的/WEB-INF/lib 和/WEB-INF/classes目录的变化,自动装载修改或新的bean
及servlet,我们可以在不重起tomcat的情况下看到bean带给jsp的变化。
2.启动你Tomcat4.1.12,在浏览器的地址中输入http://localhost:8080/oa,如你的jsp及bean,servlet没有错误,一般会将你的index.jsp/index.html文件的
内容给执行并显示。
小结:若到此步骤没有任何错误,那可继续下面的操作,Let' go!
d、整合步骤
首先假定Apache2和Tomcat4已经安装完成,安装目录分别为:[Apache_install_dir]和[Tomcat_install_dir]。并且Apache的服务端口为80,Tomcat服务端口为8080。
i:在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
Alias /examples "d:/tomcat/examples"

ii:配置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,为了后面测试用。
iii:配置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=[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
iv:测试
以上配置完毕后,整合就成功了。启动Apache。(不必手工启动Tomcat,Apache会自动在后台启动Tomcat,Tomcat的屏幕输出被重新定向到[Apache_install_dir]/logs/stdout.log和stderr.log中。
打开浏览器,访问 http://localhost/examples/
哈哈!成功了没有?




话题树型展开
人气 标题 作者 字数 发贴时间
13203 Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 zzhangwa 4017 2003-05-06 19:49
12025 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 ditty 2774 2003-05-15 10:00
11582 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 scottding 21 2003-05-15 11:34
11759 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 ditty 73 2003-05-15 11:39
11207 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 robornet 26 2003-05-18 15:06
11546 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 frankwater 78 2003-06-07 18:44
11115 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 大漠第一仙 7 2003-06-14 14:35
12193 Re:Apache 2.0.43+tomcat4.1.24+mod_jk2-2.0.43.dll的整合过程 灯泡 40 2003-06-19 13:12

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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