Tomcat 和 Apache 使用mod_jk2连接的简单说明

类别:Java 点击:0 评论:0 推荐:

Apache和Tomcat连接的方法大致有JK1.x, JK2, mod_webapp三种connector可以使用,下面简单说明一下
  Apache2.0.50 + Tomcat5.0.29 + mod_jk2的连接方法,环境为windows XP

1、下载:
       apache2.0.50从http://apache.org下载
       tomcat5.0.28从http://jakarta.apache.org下载
       module_jk2从http://jakarta.apache.org下载
2、安装
      Apache到D:\Apache Group\Apache2
      Tomcat到E:\work\jakarta-tomcat-5.0.28
      module文件为jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip 解压缩,将modules/mod_jk2.so拷贝到
     D:\Apache Group\Apache2\modules下,conf/workers2.properties.sample拷贝到D:\Apache Group\Apache2\conf下,
     并改名为worker1.properties
3、修改D:\Apache Group\Apache2\conf\httpd.conf,增加
     LoadModule jk2_module "modules/mod_jk2.so"
     JkSet config.file "conf/workers2.properties"
   
    Apache配置完毕,重新启动Apache
4、tomcat默认支持ajp1.3的jk2连接,所以只需要配置apache就可以,剩下的就是将需要访问的目录增加到
     worker2.properties就可以了,默认为
[shm]
info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
file=anon

# Defines a load balancer named lb. Use even if you only have one machine.
[lb:lb]

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
group=lb

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
group=lb

[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:
[shm]
info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.
file=D:/Apache Group/Apache2/logs/jk2.shm
size=1048576

需要修改一下apache的默认目录,然后我增加了两个目录/servlets-examples和/axis,得到如下

# Defines a load balancer named lb. Use even if you only have one machine.
[lb:lb]

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=localhost

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
group=lb

# Map the Tomcat examples webapp to the Web server uri space
[uri:/jsp-examples/*]
group=lb
[uri:/bbs/*]
group=lb
[uri:/servlets-examples/*]
group=lb
[uri:/axis/*]
group=lb
[status:]
info=Status worker, displays runtime information

[uri:/jkstatus/*]
info=The Tomcat /jkstatus handler
group=status:

[uri:/*.jsp]
worker=ajp13:localhost:8009
     
重新启动apache,tomcat
访问
http://localhost/jkstatus/
http://localhost/servlets-examples/
http://localhost/axis/
http://localhost:8080/servlets-examples/
http://localhost:8080/axis
看一下结果,如果还要增加新的目录,只要照上面操作即可

本文地址:http://com.8s8s.com/it/it12251.htm