The Apache 和Tomcat Connector 连接 快速指导 - Generic HowTo
Tomcat与HTTP服务器集成的原理
Tomcat服务器通过Connector连接器组件与客户程序建立连接,Connector组件负责接收客户的请求,以及把Tomcat服务器的响应结果发送给客户。默认情况下,Tomcat在server.xml中配置了两种连接器:
<!-- Define a non-SSL Coyote HTTP/1.1
Connector on port 8080 -->
<Connector port="8080"
maxThreads="150"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
redirectPort="8443"
acceptCount="100"
debug="0"
connectionTimeout="20000"
disableUploadTimeout="true" />
<!-- Define a Coyote/JK2 AJP 1.3
Connector on port 8009 -->
<Connector port="8009"
enableLookups="false"
redirectPort="8443" debug="0"
protocol="AJP/1.3" />
第一个连接器监听8080端口,负责建立HTTP连接。在通过浏览器访问Tomcat服务器的Web应用时,使用的就是这个连接器。
第二个连接器监听8009端口,负责和其他的HTTP服务器建立连接。在把Tomcat与其他HTTP服务器集成时,就需要用到这个连接器。
Web客户访问Tomcat服务器上JSP组件的两种方式如图
快速配置JK连接器连接 APACHE 和tomcat
workers.properties 是JK连结器接口的命令配置文件
一个实例workers.properties
使用ajp13 连结Apache webserver和 Tomcat engine
workers.properties如下:
worker.list = worker1
#Setproperties for worker1(ajp13)
worker.worker1.type = ajp13
worker.worker1.host = localhost
worker.worker1.port = 8009
你必须有mod_jk.so(unix+liunx)下 windows下面是mod_jk.dll(早期版本) 现在的版本也是.so结尾的了 应为apache
windows版本2.0以上都是.so文件的结尾
如下官方的版本说明(下载地址)
http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.23/
Apache Tomcat JK 1.2.23 for WIN32
mod_jk - apache - 1.3 . 37 .so is for Apache 1.3 ,andworkswithApache 1.3 . 37 andlater.Renametomod_jk.sobeforeputtingit in yourApache2 / modulesdirectory.
mod_jk - apache - 2.0 . 59 .so is for Apache 2.0 ,andworkswithApache 2.0 . 59 andlater.Renametomod_jk.sobeforeputtingit in yourApache2 / modulesdirectory.(这个是我现在用的版本,配置成功我的APACHE是apache_2. 0.55 - win32 - x86 - no_ssl.msi)
mod_jk - apache - 2.2 . 4 .so is for Apache 2.2 ,andworkswithApache 2.2 . 4 andlater.Renametomod_jk.sobeforeputtingit in yourApache2 / modulesdirectory.
isapi_redirect.dll is for IIS 5 andlaterWebServer.
jk_symbols.zipcontansdebug(.pdb)information for allmodules.
Unix 的目录结构:
/usr/lib/apache/
/usr/lib/apache2/
/usr/local/apache/libexec/
一般Windows下的目录结构 :
C:\Program Files\Apache Group\Apache\modules\
C:\Program Files\Apache Group\Apache2\modules\
修改http.conf
常见Unix下目录结构:
/etc/httpd/conf/
/etc/httpd2/conf/
/usr/local/apache/conf/
Windows常见目录结构 :
C:\Program Files\Apache Group\Apache\conf\
C:\Program Files\Apache Group\Apache2\conf\
在http.conf最后面加上
#Update this pathtomatchyourmoduleslocation
LoadModulejk_modulelibexec / mod_jk.so
#Declarethemodule for < IfModuledirective > (在apache 2 .0以上不要加载了)
AddModulemod_jk.c
#Wheretofindworkers.properties
#Update this pathtomatchyourconfdirectorylocation(putworkers.propertiesnexttohttpd.conf)
JkWorkersFile / etc / httpd / conf / workers.properties
#Wheretoputjksharedmemory
#Update this pathtomatchyourlocalstatedirectoryorlogsdirectory
JkShmFile / var / log / httpd / mod_jk.shm
#Wheretoputjklogs
#Update this pathtomatchyourlogsdirectorylocation(putmod_jk.lognexttoaccess_log)
JkLogFile / var / log / httpd / mod_jk.log
#Setthejkloglevel[debug / error / info]
JkLogLevelinfo
#Selectthetimestamplogformat
JkLogStampFormat " [%a%b%d%H:%M:%S%Y] "
#Sendeverything for context / examplestoworkernamedworker1(ajp13)
JkMount / examples /**/ /*worker1