日期:2014-05-17  浏览次数:20962 次

apache2.2 和Tomcat整合
1.下载Apache Http Server 2.2和Tomcat到本地安装。
2.http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries这个目录下,根据下载的Http Server 和硬件环境,下载mod_jk-1.2.26-httpd-2.2.4.so(此处根据情况下载),并重命名为:mod_jk.so,并放在Http Server/modules目录下。
3.在Http Server/conf目录下新建一个文件,名为:workers.properties
worker.list=ajp13
worker.ajp13.type=ajp13  
#worker.ajp13.host=172.16.66.89
#worker.ajp13.host=127.0.0.1
worker.ajp13.port=8009    #tomcat ajp1.3对应的端口号
worker.ajp13.lbfactor=50
worker.ajp13.cachesize=10
worker.ajp13.cache_timeout=600
worker.ajp13.socket_keepalive=1
worker.ajp13.socket_timeout=300

4.在Http Server/conf目录下新建一个文件,名为:mod_jk.conf

#Where to find workers.properties
#JkWorkersFile "D:/Program Files/Apache Software Foundation/Apache2.2/conf/workers.properties"

#Where to put jk logs 日志路径
JklogFile "D:/Program Files/Apache Software Foundation/Apache2.2/logs/mod_jk.log"

#Set the jk log level[debug/error/info] 日志级别
JkLogLevel debug

#Select the log format 日期格式
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

#JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

#JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

#Send servlet for context /examples to worker named ajp13
#JkMount /servlet/* ajp13
#Send JSPs for context /examples to worker named ajp13

#JkMount /routonlifeSystemAdmin/* worker1
#JkMount /routonlifeClient/* worker1

#JkMount /notice/*.* ajp13
#JkMount /routon/*.do ajp13
#JkMount /routon/*.action ajp13
JkMount /routon/*.* ajp13  #ajp13这个名称跟workers.properties中worker.list=ajp13要对应,表示, /routon/下所有的请求都经过ajp13协议找到对应的tomcat,由tomcat处理。

5.在Http Server/conf中,修改httpd.conf,添加:
LoadModule jk_module modules/mod_jk.so
Include "D:\Program Files\Apache Software Foundation\Apache2.2\conf\mod_jk.conf"
以上配置好了后,启动tomcat,Http Server ,然后通过Http://IP就可以访问了。
在工作中,是将静态的HTML放到Http Server/htdocs,然后通过这些静态页面中的链接来请求Tomcat中的动态信息,如此处配置的,根据链接中包含/routon/*.*,就可以请求tomcat中指定的链接!