准备工作:
1.下载apache(建议下原码包)
2.下载tomcat
3.下载jakarta-tomcat-connectors
编译安装:
1.解压编译安装apache:
shell> configure --prefix=/your/apache/path
shell> make
shell> make install
2.解压tomcat到你希望的路径
3.解压编译安装jakarta-tomcat-connectors,注意jk模块位于jk/native
shell> cd jakarta-tomcat-connectors-version-src/jk/native
shell> configure --with-apxs=/your/apache/path/bin/apxs
shell> make
shell> cp ./apache-2.0/mod_jk.so /your/apache/path/modules/
配置:
1.在apache配置文件中加载jk模块:
shell> vim http.conf
在LoadModule处加入如下内容
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkMountFile conf/uriworkermap.properties
JkLogLevel warn
JkLogFile logs/mod_jk.log
2.在apache的conf目录下,建立workers.properties文件
shell> vim conf/workers.properties
#这里loader充当负载均衡,status为jk的状态信息
worker.list = loaders,status
#本地servlet容器1,端口默认为8009,如果本地有多个servlet,注意端口冲突
worker.tomcat1.port = 8009
worker.tomcat1.host = localhost
worker.tomcat1.type = ajp13
#localhost server 2
#worker.tomcat2.port = 8009
#worker.tomcat2.host = 192.168.1.12
#worker.tomcat2.type = ajp13
#负载均衡,这里名为loaders
worker.loaders.type = lb
worker.retries = 3
worker.loaders.balanced_workers = tomcat1
#多个的话用“,”分开
#worker.loaders.balanced_workers = tomcat1,tomcat2
worker.loaders.sticky_session = 1
#jk状态信息
worker.status.type = status
3.在apache的conf目录下建立uriworkermap.properties
shell> vim uriworkermap.properties
#表示除jkstatus由status处理外,其它有loaders处理
/* = loaders
/jkstatus = status
#!表示后面信息不由servlet处理,直接由apache处理
! /*.gif = loaders
! /*.jpg = loaders
! /*.png = loaders
! /*.css = loaders
! /*.js = loaders
! /*.htm = loaders
! /*.html = loaders
! /*.xhtml = loaders
启动tomcat,apache
1.tomcat
shell> bin/start.sh &
2.apache
shell> bin/apachectl start&
如果没什么意外的话,apache与tomcat的Jk整合就应该没问题了。
阅读(1161) | 评论(0) | 转发(0) |