apache http server 和tomcat整合

来源:互联网 发布:多重网络怎么解决方法 编辑:程序博客网 时间:2024/05/18 03:54

apache 2.2.11,tomat 1.6.0_07,

jk从http://tomcat.apache.org/connectors-doc/下载对应版本的.

总结一下,基本上都是配置的apache这一头儿的conf目录下的文件.

httpd.conf
#Apache 服务器的配置文件,用来加载 JK 模块以及指定 JK 配置文件信息

#用实际下载的名称,也可以改名

LoadModule jk_module modules/mod_jk.so.

#
# Configure mod_jk
#

JkWorkersFile conf/workers.properties
JkMountFile conf/uriworkermap.properties
JkLogFile logs/mod_jk.log
JkLogLevel warn

workers.properties
# 到 Tomcat 服务器的连接定义文件,需要实际的port,和host,tomcat的port8009,8010如果被jvm占用,需要在tomcat的server.xml上改为未占用的.我的8009,8010端口被jvm占用,我在server.xml添加两个ajp端口为8109和8209,一共三个worker.

#
# workers.properties
#
# list the workers by name
worker.list=DLOG4J, status
# localhost server 1
# ------------------------
worker.s1.port=8109
worker.s1.host=localhost
worker.s1.type=ajp13
# localhost server 2
# ------------------------
worker.s2.port=8209
worker.s2.host=localhost
worker.s2.type=ajp13
worker.s2.stopped=1
worker.DLOG4J.type=lb
worker.retries=3
worker.DLOG4J.balanced_workers=s1, s2
worker.DLOG4J.sticky_session=1
worker.status.type=status
uriworkermap.properties
#URI 映射文件,用来指定哪些 URL 由 Tomcat 处理,你也可以直接在 httpd.conf 中配置这些 URI,但是独立这些配置的好处是 JK 模块会定期更新该文件的内容,使得我们修改配置的时候无需重新启动 Apache 服务器。http://localhost/jkstatus能够显示jk状态

/*=DLOG4J
/jkstatus=status
!/*.gif=DLOG4J
!/*.jpg=DLOG4J
!/*.png=DLOG4J
!/*.css=DLOG4J
!/*.js=DLOG4J
!/*.htm=DLOG4J
!/*.html=DLOG4J

80端口配置给了apache http;;;;;;;;;;;;;;;;;;;8080,8109,8209配置给tomcat

http://localhost被转发到http://localhost:8080,如果apache http没有内容,全部使用tomcat的,把!/*那些行删除.

另外,需要配置禁止访问web-inf和其他的系统tomcat目录;但我没有设置,同样限制访问web-inf.

 

转:http://hi.baidu.com/5665777/blog/item/1ae6e9fdf4a95942d6887dbe.html

原创粉丝点击