mod_jk是 Tomcat 与 Apache 之间的桥梁,因此您可以专注于您的应用程序,而 Apache 作为前端,可以处理 https 和身份验证等。它会将某些 URL 转发给 Tomcat 中的“workers”。所以你需要告诉Apache加载mod_jk,你需要配置worker.properties,Apache需要知道哪个worker做什么,你需要在Tomcat中定义一个Service。
httpd.conf 中的这些指令配置 mod_jk:
JKWorkersFile conf/workers.properties
JKLogFile /var/log/tomcat/mod_jk.log JKLogLevel 信息
/etc/httpd/conf/workers.properties 中的 JKWorkersFile 基本上定义了套接字
workers.tomcat_home=/var/tomcat4
workers.java_home=/usr/java/jdk
ps=/
worker.list=worker1,worker2
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker2.port=8010
worker.worker2.host=localhost
worker.worker2.type=ajp13
httpd.conf 的这个片段会将所有内容(即 /* )委托给 worker1:
<VirtualHost 192.0.34.72>
ServerAdmin webmaster@ example.com
DocumentRoot /www/www.example.com/webapps/ROOT
ServerName www.example.com
ErrorLog logs/public_errors
LogLevel debug
CustomLog logs/public_access combined
JkMount /* worker1
<Directory "/www/www. example.com/webapps/ROOT">
Options Indexes FollowSymLinks Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location "/WEB-INF/">
AllowOverride None
deny from all
</Location>
<Location "/META-INF/">
AllowOverride None
deny from all
</Location>
</VirtualHost>
Tomcat 会有这个服务:
<service name="public">
<connector classname="org.apache.coyote.tomcat4.CoyoteConnector" port="8009" minprocessors="5" maxprocessors="75" enablelookups="true" redirectport="8443" acceptcount="10" debug="0" connectiontimeout="0" useurivalidationhack="false" protocolhandlerclassname="org.apache.jk.server.JkCoyoteHandler" />
<engine name="Standalone" defaulthost="localhost" debug="0">
<logger classname="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true" /> <realm classname="org.apache.catalina.realm.UserDatabaseRealm" debug="0" resourcename="UserDatabase" /> 
<host name="localhost" debug="0" appbase="/www/www.example.com/webapps" unpackwars="true" autodeploy="true">
<logger classname="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" />
</host>
</engine>
</service>
以上示例来自我的笔记,请查看更新文档:http:
//tomcat.apache.org/connectors-doc/generic_howto/workers.html
http://tomcat.apache.org/connectors-doc/webserver_howto/apache。 html