http://tomcat.apache.org/connectors-doc/generic_howto/quick.html
搭建最简单的tomcat connector
用到了apapche 的mod_jk 模块 。
下载编译 tomcat connector
- wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz
- tar xzf tomcat-connectors-1.2.40-src.tar.gz
- cd tomcat-connectors-1.2.40-src
- yum install httpd-devel -y
- cd native/
- which apxs
- ./configure --with-apxs=/usr/sbin/apxs
- make && make install
- 编译完了以后会得到一个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>