一、安装mode_jk模块
  下载源码包:http://mirrors.shu.edu.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.42-src.tar.gz
  解压进入native目录
  编译:

  ./configure --with-apxs=/usr/bin/apxs
  make

  如果没有apxs安装httpd-devel包

  拷贝生成的链接库到httpd的模块目录

  cp apache-2.0/mod_jk.so /etc/httpd/modules

二、配置httpd
在conf.d目录下添加配置文件mod_jk.conf

JkWorkersFile /etc/httpd/conf/workers.properties
JkLogFile /var/log/httpd/mode_jk.log
JkLogLevel info
#JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkMount / worker1
JkMount /* worker1
#JkMount /teacher-platform worker1
#JkMount /teacher-platform/* worker1
#JkMount /* workker1
#JkAutoAlias /use/local/apache2/htdocs

相应目录下添加worker.properties

workers.tomcat_home=/var/www/tomcat
workers.java_home=/opt/jdk7
ps=/
worker.list=worker1    #可指定多个,逗号分隔
worker.worker1.type=ajp13
worker.worker1.host=teacher-platform.hospital-seminar.com
worker.worker1.port=8009

注意:JkMount 后面的worker1要和worker.list中的值对应,同时要和tomcat server.xml中Engine标签jvmRoute参数对应

三、添加虚拟网站

<VirtualHost *:80>
ServerName www.hospital-seminar.com
ServerAlias hospital-seminar.com
DocumentRoot "/var/www/tomcat/webapps/"
JkMount / worker1
JkMount /* worker1
#JkMount /teacher-platform worker1
#JkMount /teacher-platform/* worker1
JkMount /jkstatus status
</VirtualHost>

四、配置tomcat
确保标签存在

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

对于单个tomcat实例,以下是可选的:添加jvmRoute参数,唯一标识一个tomcat实例

<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">

添加一个Host

<Host name="teacher-platform.hospital-seminar.com" appBase="webapps"         
 unpackWARS="true" autoDeploy="true">
 <Context path="" docBase="teacher-platform" debug="0" reloadable="true">
</Context>
</Host>

注意:worker.properties中worker对应的host和server.xml中Host的name对应

五、重启httpd和tomcat


 

参考:http://www.flashguides.co.uk/guide/Integrating_Apache_and_Tomcat_with_Virtual_Hosts

posted on 2018-02-23 16:33  浮舟z  阅读(201)  评论(0编辑  收藏  举报