Monday, 21 March 2016

How to configure mod_jk ?


Step 1. Configure httpd.conf
After you installed mod_jk, you need to configure it in your httpd.conf file so that you can use it. You can find httpd.conf in the 'conf' directory of your Apache HTTPD home folder.
Below is the minimum configuration required for mod_jk to run correctly.  Replace the placeholder paths with the correct paths and values for your system.

# Load the mod_jk module.  
LoadModule    jk_module  path/to/mod_jk.so

# Declare the module for use with the element.
# (This only applies to versions of HTTPD below 2.x.  For 2.x and above, Remove this line)
AddModule     mod_jk.c

# Set path to workers.properties. We will create this file in the next step.
# The file will be placed in the same directory as httpd.conf.
JkWorkersFile /path/to/httpd/conf/workers.properties

# Set path to jk shared memory.  Generally, you'll want this to point to your local state or logs directory.
JkShmFile     /path/to/log/httpd/mod_jk.shm

# Where to put jk logs ? Set path to jk logs.  This path should point to the same logs directory as the HTTPD access_log.
JkLogFile     /path/to/log/httpd/mod_jk.log

# Set the jk log level.  Valid values for this setting are 'debug', 
'error', or 'info'.
JkLogLevel    level

# Set timestamp log format.  Use provided variables to customize.
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# Map a worker to a namespace.  Workers represent Tomcat instances that are listening for requests.
# For the sake of this example, Tomcat's "examples" context is used, and a default worker named 'worker1'.
# Multiple JkMount attributes can be used simultaneously.
JkMount  /examples/* worker1


Step 2. Configure workers.properties
The workers.properties file defines a list of Tomcat 'workers' to which Apache HTTPD can pass requests.  
The configuration below defines the ajp13 worker named 'worker1' to handle all requests for the "examples" context
# Define a worker named 'worker1' (more workers can be added as comma separated values)
worker.list=worker1
# Set worker properties
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

However, the workers.properties file can become quite complex in practice, containing multiple types of workers, virtual workers, and parts of a clustering or load balancing configuration.


Step 3 - Test Configuration
After completing the steps above, restart Apache HTTPD and navigate to the examples context.
If your configuration is correct, the page will display as normal. 
If you experience any strange errors, Apache's Tomcat Connector FAQ is a good resource to help you track down the source.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.