用apache配置多个tomcat webapp

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT.

     Apache Tomcat is the servlet container that is used in the official Reference Implementation for the java Servlet and JavaServer Pages technologies.

     apache2.2 和tomcat6到www.apache.org官方网站下载。

     tomcat 5 版本以后通过ajp13连接器(之前ajp12)与apache相连,tomcat ajp监控端口默认为8009。

     以tomcat6.0为例,需要以下步骤:

    从从tomcat.apache.org下载 连接器

1    下载连接器文件:

url(for win32): http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.26/mod_jk-1.2.26-httpd-2.2.4.so

url(for linux):

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.26/x86_64/mod_jk-1.2.26-httpd-2.2.6.so

2   将下载的so文件放置到apachDir/modules目录下

3   在apacheDir/conf目录下新增workers.properties文件,并添加如下内容:

ps=\

workers.tomcat_home=D:\devtool\apache-tomcat-6.0.14

workers.java_home=C:\java\jdk1.5.0_11

worker.list=worker1,worker2

worker.worker1.port=8009

worker.worker1.host=127.0.0.1

worker.worker1.type=ajp13

worker.worker2.port=8009

worker.worker2.host=127.0.0.1

worker.worker2.type=ajp13

 该文件中定义了2个worker,对应2个web应用,这里只指向同一个tomcat,实际中可以指向不同的机器或不同的端口。

3   修改apache的配置文件conf/httpd.conf:

找到最后一个LoadModule ,在下面添加:

 LoadModule jk_module modules/mod_jk-1.2.26-httpd-2.2.4.so

JkWorkersFile F:/Apache2.2/conf/workers2.proerties

JkLogFile jklog.log

# Set the jk log level [debug/error/info]

JkLogLevel info

# Select the timestamp log format

JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

# Send servlet for context /examples to worker named worker1

# JkMount /examples/servlet/* worker1

# Send JSPs  for context /examples to worker named worker1

#example webapp

JkMount  /examples/* worker1

#statistic webapp

JkMount  /statistic/* worker2

至此,设置结束,

重启apache,打开tomcat6

我们试验一下效果 :打开浏览器,地址栏输入:http://localhost/examples/

用apache配置多个tomcat webapp,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。