Apache + tomcat (mod_jk)

1. Install Apache, Tomcat and mod_jk

Install Apache (with devel package), Tomcat (with webapps package) and apache2-mod_jk. start both. You can check Apache by pointing your browser at localhost and Tomcat by pointing your browser at localhost:8080 (you should get the default start page).

2. Configure mod_jk

Next, edit /etc/apache2/httpd.conf and add:

# Load mod_jk module
LoadModule jk_module modules/mod_jk.so

JkWorkersFile /local/tomcat/conf/jk/workers.properties

# Where to put jk logs
JkLogFile /local/apache2/logs/mod_jk_log

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

# 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”

# Send servlet for context /examples to worker named worker1
JkMount /your-url/* worker1

You can do this alternatively in your vhost. This configuration will send all jsp’s and all in the path /servlets-examples/* to Tomcat. If you know the exact path to your servlet, you can write:

JkMount /trn-webapp-0.8.1/map worker1

for example, where map is the servlet

Next, create /etc/apache2/workers.properties with the following content:


Then, goto /etc/tomcat5/base/ and check your server.xml. You should find something like this:

Make sure, it is enabled (without ).

At this point, you can edit also your /etc/tomcat5/base/tomcat-users.xml. You can replace it with this:

You should replace root and password with your own settings

For testing purposes, edit httpd.conf and set Document Root, Directory and Options:

ScriptAlias /modjk/ /usr/local/apache/modjk/

AllowOverride None
Options none
Order allow,deny
Allow from localhost

Now first restart Tomcat, then Apache. (If you change something in Tomcat, everytime restart Tomcat first and then restart Apache, too!)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: