In an earlier article, I promised to demystify Tomcat's server.xml file. Now, I'd like to advance the discussion with an in-depth look at the JK modules. This is the first of five articles addressing JK. Here's a preview of the whole series:
- Configuring Tomcat and Apache using JK v1.2
- Configuring Tomcat and IIS using JK v1.2
- Configuring Tomcat and Apache using JK v2
- Configuring Tomcat and IIS using JK v2
- Advanced Connector Configurations
What is JK v1.2?
In the simplest terms, the JK modules, or
mod_jk, are conduits between a Web server and the Tomcat JSP/servlet container. They replace the previous Web server module,
mod_jserv, which had many shortcomings. The new JK modules include support for a wider variety of Web servers, better SSL support, support of the AJP13 protocol, and support for the entire Tomcat series from 3.2.x to 5.x.
Preparing Your Environment
Before we can continue with our discussions, you must get all of the components required to configure Tomcat and Apache. The following lists these components and their current locations.
The AJP 13 protocol is a packet-based protocol that allows a Web server to communicate with the Tomcat JSP/servlet container over a TCP connection. For our purposes, all that we need to know is that AJP13 is a more efficient protocol and includes better support for SSL than its predecessors. Further information on AJP13 is available at http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/common/AJPv13.html.
Make sure that you download the appropriate binary for your operating system. You can download the source for each of these components, but we will not be covering the building of any of them. Once you have downloaded all of the components listed above, complete the following steps:
Install Apache as described in its packaged documentation.
Test the Apache installation, by starting Apache and opening your browser to http://localhost. You should now see an image similar to Figure 1.
Figure 1. The Apache Installation Test Page
Install Tomcat as described by its documentation.
Set the environment variable
JAVA_HOMEequal to the root directory of your JDK installation.
Set the environment variable
CATALINA_HOMEequal to the root directory of you Tomcat installation.
Test the Tomcat installation by starting Tomcat and opening your browser to http://localhost:8080. You should now see an image similar to Figure 2.
Figure 2. The Tomcat Default Homepage
Now shut down both Apache and Tomcat, before moving on to the next sections.
Configuring Tomcat and Apache With the JK 1.2 Connector
It is now time to begin the actual integration between Apache and Tomcat. This process can be broken down into two sections: configuring Tomcat and configuring Apache.
To begin our Tomcat and Apache integration, we need to first tell Tomcat that it should start listening for AJP13 requests; both JK and JK2 use AJP13 to communicate with Tomcat. To do this, we need to add an additional
<Connector> element to Tomcat's server.xml file. Add the following entry to server.xml, making sure that it is inside of the
<Service> element and immediately follows any previously-defined
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector" port="8009" minProcessors="5" maxProcessors="75" acceptCount="10" debug="0"/>
The only two attributes in this
<Connector> worth noting are the
className attributes. The
port attribute tells Tomcat that it needs to open a new
Connector that listens to port 8009 for incoming requests. The
className attribute tells Tomcat that all of the requests coming in on this port should be serviced by the Tomcat Connector class
org.apache.ajp.tomcat4.Ajp13Connector, which also uses the AJP 1.3 protocol. (If you have further questions about Tomcat Connectors, you can refer to "Demystifying Tomcat's server.xml File.")
This completes the Tomcat configuration.
Pages: 1, 2