Configure mod_jk for Apache 2.2 and Tomcat 7

 

Environment

# cat /etc/redhat-release
CentOS release 6.2 (Final)
# uname -a
Linux openidmbox.mytest.local 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux
# hostname
openidmbox.mytest.local

Prerequisites

* Install Apache 2

# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Dec  8 2011 18:10:49

* Install Tomcat

# cat RELEASE-NOTES |grep Version
  The ASF licenses this file to You under the Apache License, Version 2.0
                     Apache Tomcat Version 7.0.30

Download mod_jk Binary

* Download mod_jk-1.2.31-httpd-2.2.x.so since our httpd version is 2.2.15

cd /etc/httpd/modules
wget http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/x86_64/mod_jk-1.2.31-httpd-2.2.x.so
ln -s mod_jk-1.2.31-httpd-2.2.x.so mod_jk.so

* Check here for other mod_jk binaries.

Configure mod_jk for Apache

* Create /etc/httpd/conf/workers.properties file:

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

* Create /etc/httpd/conf.d/mod_jk.conf file:

# Load mod_jk module
LoadModule    jk_module  modules/mod_jk.so
 
# Where to find workers.properties
JkWorkersFile /etc/httpd/conf/workers.properties
 
# Where to put jk shared memory
JkShmFile     /var/log/httpd/mod_jk.shm
 
# Where to put jk logs
JkLogFile     /var/log/httpd/mod_jk.log
 
# Set the jk log level [debug/error/info]
JkLogLevel    info
 
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
 
# Send all requests for context /examples to worker named worker1
JkMount  /examples* worker1
 
# Other mount examples:
# Send servlet for context /examples to worker named worker1
#JkMount  /examples/servlet/* worker1
# Send JSPs  for context /examples to worker named worker1
JkMount  /examples/*.jsp worker1
#JkMount /webapp* ajp13
#Mount the webapp context

* Check that all config files in conf.d directory is loaded in httpd.conf file:

#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf

Test

* Restart httpd
service httpd restart
* Point browser to http://openidmbox/examples/. Note that we are using port 80 instead of port 8080.

mod_jk_config

References

* http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
* http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/
* http://tomcat.apache.org/connectors-doc-archive/jk2/jk/quickhowto.html
* http://anujjaiswal.wordpress.com/2011/06/15/configuring-mod_jk-tomcat-7-0-and-apache-2-2/

This entry was posted in apache, tomcat and tagged , , . Bookmark the permalink.

One Response to Configure mod_jk for Apache 2.2 and Tomcat 7

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.