alonli 发表于 2017-1-4 07:47:05

The Apache和Tomcat Connector连接

  Tomcat与HTTP服务器集成的原理
  
  Tomcat服务器通过Connector连接器组件与客户程序建立连接,Connector组件负责接收客户的请求,以及把Tomcat服务器的响应结果发送给客户。默认情况下,Tomcat在server.xml中配置了两种
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如下:
  # Define 1 real worker using ajp13
  worker.list=worker1
  # Set properties 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
  Here you'll find the binaries for IIS, Apache and Sun ONE Web Servers.
  
mod_jk-apache-1.3.37.so is for Apache 1.3, and works with Apache 1.3.37 and later. Rename to mod_jk.so before putting it in your Apache2/modules directory.
mod_jk-apache-2.0.59.so is for Apache 2.0, and works with Apache 2.0.59 and later. Rename to mod_jk.so before putting it in your Apache2/modules directory. (这个是我现在用的版本 ,配置成功 我的APACHE 是apache_2.0.55-win32-x86-no_ssl.msi)
mod_jk-apache-2.2.4.so is for Apache 2.2, and works with Apache 2.2.4 and later. Rename to mod_jk.so before putting it in your Apache2/modules directory.
isapi_redirect.dll is for IIS 5 and later Web Server.
jk_symbols.zip contans debug (.pdb) information for all modules.
  
 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最后面加上
  # Load mod_jk module
  # Update this path to match your modules location
  LoadModule    jk_module  libexec/mod_jk.so
  # Declare the module for <IfModule directive> ( 在apache 2.0以上不要加载了)
  AddModule     mod_jk.c
  # Where to find workers.properties
  # Update this path to match your conf directory location (put workers.properties next to httpd.conf)
  JkWorkersFile /etc/httpd/conf/workers.properties
  # Where to put jk shared memory
  # Update this path to match your local state directory or logs directory
  JkShmFile     /var/log/httpd/mod_jk.shm
  # Where to put jk logs
  # Update this path to match your logs directory location (put mod_jk.log next to access_log)
  JkLogFile     /var/log/httpd/mod_jk.log
  # Set the jk log level
  JkLogLevel    info
  # Select the timestamp log format
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  # Send everything for context /examples to worker named worker1 (ajp13)
  JkMount  /examples/**//* worker1
  

 
页: [1]
查看完整版本: The Apache和Tomcat Connector连接