Installing JK Connector for Tomcat 6 with Apache2

This is a simple howto for those who want to run tomcat applications and/or services without having to always specify the port (8080).

Step 1: Install libapache2-mod-jk
sudo apt-get install libapache2-mod-jk

Step 2: Check whether there is jk.load in the apache 2 modules

sudo ls /etc/apache2/mods-enabled/

If it is not there, enable it.

a2enmod jk

Step 3: Edit and save

sudo vi /etc/libapache2-mod-jk/

and set:


Please enter the correct paths for your system.

Step 4: Let Apache2 know where to find the workers file and where to log, etc

sudo vi /etc/apache2/mods-enabled/jk.load

and add the following:

# Where to find
JkWorkersFile /etc/libapache2-mod-jk/

# Where to put jk logs
JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel debug

# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

Step 5: Edit 000-default to mount a directory to use Tomcat

sudo vi /etc/apache2/sites-enabled/000-default

Then paste the following content just before the </VirtualHost> tag.

# Configuration for mod_jk
# Send servlet for context / jsp-examples to worker named ajp13_worker
JkMount /examples ajp13_worker
# Send JSPs for context /jsp-examples/* to worker named ajp13_worker
JkMount /examples/* ajp13_worker

Step 6: Edit server.xml and uncomment a line

sudo vi /etc/tomcat6/server.xml

Remove the comments around the following.

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

Step 7: Restart apache2

sudo /etc/init.d/apache2 restart

Step 8: Restart tomcat

sudo /etc/init.d/tomcat6 restart

Now the basic setting is finished. You can test by loading the following two urls:


Both should load the page. The second uses mod_jk.

By Brian Last updated: 1 November 2012, 20:48