This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Apache + Tomcat configuration

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am pretty sure, someone will be able to help me on this. I installed Tomcat standalone and did some performance testing with my servlet. The results are quite bad.
I am hoping that if I configure Tomcat to work with Apache, then Apache will take care of the performance required with hundreds of simultanoeus connections and might be able to give better performance. Am I right or wrong!
Also if somebody can provide a link to website/How To guide to setting up Tomcat to run with Apache, it will be very useful.
Thanks
Ritu
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right ritu, recently, just to improve performance i also used 5 tomcats with apache server using mod_jk, following links will probably help u how to setup connection between two
http://raibledesigns.com/tomcat/index.html
 
Ritu Kama
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot! I will try it out and let you know.
Ritu
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
题目:Windows2000 下整合Apache2与Tomcat4
作者:robornet
日期:2002-10-30
原由:搞了一段时间的java项目,到分发的时候了,可找不到一份最新的Apache2与Tomcat4的整合配置,遂看了半天的jakarta在线资料,并参照以前网友的文章,
写了这篇配置文档,以作参考,欢迎斧正!
目录:
一、软件准备
二、软件安装
三、首次配置及测试
四、整合配置
五、全线测试
六、不足
七、感谢
八、说明
步骤:
一、软件准备:
假设你有一台能正常运行win2000的硬软软件环境。
1.j2sdk1.4.1: 到http://java.sun.com/j2se/1.4.1/download.html下载!(注意是Windows (all languages, including English)的sdk版)
2.Apache2.0.43: 到http://www.apache.inetcosmos.org/dist/httpd/binaries/win32/apache_2.0.43-win32-x86-no_ssl.msi 下载!
3.Tomcat4.1.12:到 http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.12/bin/jakarta-tomcat-4.1.12.exe 下载!
4.mod_jk.dll: 到http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/v1.2.0/bin/win32/mod_jk-2.0.42.dll下载!;
(说明,由于mod_jk2-2.0.43.dll与Apache2.0.43配置没成功,现用mod_jk-2.0.42.dll代替)
二、软件安装:
(1)安装j2sdk:
1.按照安装向导进行安装(一般安装到C:\j2sdk1.4.1下,方便下面操作)
(2)安装apache:
1.按照安装向导进行安装(选择安装目录为C:\,方便下面操作;安装成功后其路径为:C:\Apache2)
(3)安装Tomcat:
1.按照安装向导进行安装(更改安装目录为C:\Tomcat4,若只是测试,没必要把tomcat安装成Services,方便下面操作),
其间会要你输入Admin(系统管理员)的口令。
三、首次配置及测试:
对以上安装的软件环境进行首次配置,并测试其环境。
(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工作正常.(注意,Tomcat默认端口为80,
若有其它程序占用,请更改,下面有说明)
2.打开浏览器,在地址栏中输入:http://localhost:8080 检验:此时能在浏览器中看到Tomcat的欢迎界面.说明Tomcat工作正常.(注意,Tomcat默认端口为
8080,若有其它程序占用,请更改,下面有说明)
小结:若到此步骤没有任何错误,那可继续下面的操作,Let' go!
(4)测试你的项目:
现只用Tomcat测试你的项目,为方便此例说明,假设你已有一个项目在E:\Application\OA目录下
(包含index.jsp及其它jsp文件和bean,如WEB-INF\classes\下的servlet、javabean)。
1.设置Tomcat以支持你的项目,打开C:\Tomcat4\conf\server.xml文件,在"</Host>"之前,"</Context>"之后添加
<Context path="/oa" debug="0" docBase="E:\Application\OA" reloadable="true"/>并保存。
说明: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!

四、整合配置:
对Apache与Tomcat做相应的配置,让其共同为你工作。
若Apache2与Tomcat4正运行着,请关闭它们。
(1)配置Apache2:
1.先将下载的mod_jk-2.0.42.dll复制到C:\Apache2\modules下。
2.设置主页文件类型:打开C:\Apache2\conf下的httpd.conf,查找"DirectoryIndex",在index.html的后面添加index.jsp并保存,注意相互之间应有空格。
3.设置虚拟主机,让Apache自动控制html与jsp的解析: 打开C:\Apache2\conf\httpd.conf,在最后加入下面这段代码并保存。
<VirtualHost localhost> //localhost为本机,你可用本机ip
ServerAdmin robornet@robornet.com //你的mail地址
DocumentRoot E:\Application //你的项目组根目录,因为Application下有OA及其它多个项目,因此只能设为E:\Application
ServerName localhost //你的服务名,若你的机器有域名,设为域名,但现用本机作测试
ErrorLog logs/robornet_home_log.txt //错误日志,在C:\Apache2\logs下,可用其它任意名字
CustomLog logs/robornet_Custom_log.txt common //访问日志,在C:\Apache2\logs下,可用其它任意名字
</VirtualHost>
4.设置Apache与Tomcat之间的连接,让Apache遇到jsp文件时,在后台将其交由Tomcat去处理:打开C:\Apache2\conf\httpd.conf,在最后加入下面这段代码并保存。
# Using mod_jk2.dll to redirect dynamic calls to Tomcat
LoadModule jk_module modules/mod_jk-2.0.42.dll //装载模块,用于处理连接
JkWorkersFile "C:/Tomcat4/conf/workers.properties" //设置模块的工作文件,下面会说明
JkLogFile "C:/Tomcat4/logs/mod_jk2.log" //设置模块工作的日志文件,Tocmat启动时会自建
JkMount /servlet/* ajp13 //让Apache支持对servlet传送,用以Tomcat解析
JkMount /*.jsp ajp13 //让Apache支持对jsp传送,用以Tomcat解析
小结:到此Apache的配置基本完成,不过这时启动Apache还不能正常工作。
(2)配置Tomcat4:
1.在C:\Tomcat4\conf下新建一个文件workers.properties 注意文件后缀,建议用EditPlus或UltraEdit建立,若用记事本,记得改名,
不要成了workers.properties.txt了!其内容如下:
workers.tomcat_home=c:\Tomcat4 //让mod_jk模块知道Tomcat
workers.java_home=c:\j2sdk1.4.1 //让mod_jk模块知道j2sdk
ps=\
worker.list=ajp13 //模块版本,现有ajp14了,不要修改
worker.ajp13.port=8009 //工作端口,若没占用则不用修改
worker.ajp13.host=localhost //本机,若上面的Apache主机不为localhost,作相应修改
worker.ajp13.type=ajp13 //类型
worker.ajp13.lbfactor=1 //代理数,不用修改
2.打开C:\Tomcat4\conf下的server.xml文件:查找到"<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->",将以前的代码:
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8009"
minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000" useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5"
maxProcessors="75" acceptCount="10" debug="0"/>
-->
更改为:
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8009"
minProcessors="5" maxProcessors="75" enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="20000" useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5"
maxProcessors="75" acceptCount="10" debug="0"/>
并保存后关闭.
小结: 兄弟一定都累了吧!好了,可以来一杯java,好好享受你的成果吧!
五、全线测试:
1.启动Apache2,Tomcat4 。
2.打开你的浏览器,在地址栏中输入http://localhost:8080/oa ,若与上面的测试相同,则Tomcat重新配置后正常!
3.在地址栏中输入http://localhost/oa ,若与http://localhost:8080/oa的结果相同,那恭喜你,Apache2与Tomcat4整合成功了!!!;
六、不足:
1.虽用最新的Apache2.0.43与Tomcat4.1.12,但我是用的jk连接的,刚用jk2配置未成功,所以只好写这份文档了!
2.Tomcat还是采用的Tomcat-Standalone,未采用Tomcat-Apache,不过这个大家可以自己完成,这个应不是个问题!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear robor net
may I have the same instructions in readable versions.
Thanks a lot.
Alexey.
 
Don't play dumb with me! But you can try this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic