首先,下載mod_jk.
http://apache.mirror.phpchina.com/tomcat/tomcat-connectors/jk/binaries/
按照系統(tǒng)和apache版本找到合適的mod_jk.so。
主要看系統(tǒng)是否64位,其次使用httpd -v 命令查看apache版本。
修改apache的conf:
在apache conf 下創(chuàng)建文件:workers.properties
workers.tomcat_home="/home/youcity/tomcat"
workers.java_home="/home/youcity/jdk1.6.0_07"
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.jkstatus.type=status
修改httpd.conf
在后面加上:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkLogFile logs/mod_jk.log
JkLogLevel debug
JkMount /website_back/* ajp13
JkMount /blog/* ajp13
JkMount /demo/* ajp13
其次,修改tomcat server.xml
找到AJP設(shè)置,將其注釋去掉
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
找到此處
<!-- You should set jvmRoute to support load-balancing via AJP ie :-->
<Engine name="Catalina" defaultHost="localhost" jvmRoute="ajp13">
<!-- Define the top level container in our container hierarchy
<Engine name="Catalina" defaultHost="localhost"> -->
將上面jvmRoute的打開,下面的注釋掉,jvmRoute與apache的workers.properties設(shè)置一致。
到此處配置即成功,但如果apache有多個(gè)VirtualHost,則需要做相應(yīng)改動(dòng)。
將
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkLogFile logs/mod_jk.log
JkLogLevel debug
放到NameVirtualHost *:80后面。
JkMount 寫到具體的VirtualHost 里面
<VirtualHost *:80>
ServerAdmin webmaster@youcity.com
DocumentRoot /var/www/html
ServerName www.×××.com
JkMount /demo/* ajp13
</VirtualHost>
之后tomcat設(shè)置與之對(duì)應(yīng)的訪問(wèn)路徑
<Context path="/demo"
docBase="/home/admin/demo"
reloadable="true"/>
OK.
聯(lián)系客服