How do I connect Apache to Tomcat using the mod_jk module?
Author: Deron Eriksson
Description: This tutorial describes how to connect the Apache Web Server to Tomcat using the mod_jk module.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.4 || Tomcat 5.5.20 || Apache HTTP Server 2.2.4


Page:    1 2 >

It's quite easy to connect ApacheSW to TomcatSW using the mod_jk module. To begin with, let's set up Tomcat. In Tomcat's server.xml file, uncomment the AJP connector, as shown below.

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

I'm going to run my 'tomcat-demo' project in EclipseSW, so my server.xml file has a Context entry for 'tomcat-demo'.

	<Context docBase="C:\projects\workspace\tomcat-demo\web" path="/tomcat-demo" reloadable="true"/>

Next, I'll start up my 'tomcat-demo' project in Eclipse using a Tomcat bootstrap debug configuration (for details on how to do this, please see my other tutorials):

starting tomcat-demo project in Eclipse

In the console, when we start fire up the Tomcat bootstrap debug configuration, we can see that the AJP13 listener is listening on port 8009.

...
May 25, 2007 11:25:02 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 25, 2007 11:25:02 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/31  config=null
...

The Apache web server doesn't come with the mod_jk connector by default, so let's download it. I downloaded the mod_jk Tomcat connector from http://tomcat.apache.org/download-connectors.cgi. For this tutorial, I downloaded mod_jk-apache-2.2.4.so from /pub/apache/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.23/.

I placed mod_jk-apache-2.2.4.so in my C:\Apache2.2.4\modules\ directory.

Apache modules directory

Next, I created a worker.properties file in C:\Apache2.2.4\conf\, as shown below:

worker.properties

worker.list=myworker
worker.myworker.type=ajp13
worker.myworker.host=localhost
worker.myworker.port=8009

(Continued on page 2)

Page:    1 2 >