首页 > 代码库 > The Apache Tomcat Connector

The Apache Tomcat Connector

http://tomcat.apache.org/connectors-doc/generic_howto/quick.html

搭建最简单的tomcat connector

用到了apapche 的mod_jk 模块 。

下载编译 tomcat connector

  1. wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
  2. tar xzf tomcat-connectors-1.2.40-src.tar.gz
  3. cd tomcat-connectors-1.2.40-src
  4. yum install  httpd-devel -y
  5. cd native/
  6. which apxs
  7. ./configure --with-apxs=/usr/sbin/apxs
  8. make && make install
  9. 编译完了以后会得到一个mod_jk.so 文件,apache httpd 会用到。

 

配置一个workers.properties 文件

 

一个最小化的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
就是后端的一个tomcat的一些信息。

这个文件放在/etc/httpd/conf.d下

 

配置httpd.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> (remove this line on Apache 2.x)  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 [debug/error/info]  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

新建一个vhost

<VirtualHost 115.28.1xx.xx:80>
DocumentRoot /opt/tomcat8080/webapps
ServerName 115.28.xx
JkMount /examples/* worker1
#JkMount /servlet/* ajp13
</VirtualHost>

 

用ip/examples 访问来测试。