Tomcat 4.1.x and Apache 2.0.x on Linux with mod_jk.so

$APACHE_HOME refers to the root directory of the Apache 2.0.xx installation (which is /home/apache for this machine). $CATALINA_HOME refers to the root directory of the Tomcat 4.1.xx installation (which is /home/tomcat for this machine). Make the appropriate changes for your installation.

The mod_jk.so used in writing this documentation was built from the following source:

The Tomcat documentation indicates that future development effort is focused on mod_jk2. Unless there is a compelling reason (such as integrating with Apache httpd 1.3.x) mod_jk2 should probably be considered instead.

1.   Copy mod_jk.so to $APACHE_HOME/modules
2.   Make sure mod_jk.so is rwx for the owner of the httpd process
3.   Create a workers.properties file with the following information

{{{     # 
     # Where some things are located 
     # 
     workers.tomcat_home=/home/tomcat 
     workers.java_home=/usr/java 
     workers.apache_log=/home/apache/logs 

     # 
     # directory separator 
     # 
     ps=/ 

     # 
     # create a single worker 
     # 
     worker.list=worker1 

     # 
     # set this worker as a local ajp13 worker 
     # 
     worker.worker1.type=ajp13 
     worker.worker1.host=127.0.0.1 
     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 

4. Place this file in $APACHE_HOME/conf 5. Make sure this file is readable by owner of the Apache 2.0.x process 6. Add the following in $APACHE_HOME/conf/httpd.conf to load {{{ mod_jk.so

7. Add the following in $APACHE_HOME/conf/httpd.conf to take care of {{{ mod_jk housekeeping

NOTE: Replace /home/apache with your location of Apache 2.0.x

8.   Add the following in $APACHE_HOME/conf/httpd.conf to map the
{{{     Tomcat information.  This will allow Apache 2.0.x to serve static 
     information. 

     Alias /examples/ "/home/tomcat/webapps/examples/" 

NOTE: Replace /home/tomcat with your location of Tomcat 4.1.x

9.   Place the following information in $APACHE_HOME/conf/httpd.conf
{{{     to map the dynamic portion of /examples to Tomcat 4.1.x 

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

10. Shut down the Apache 2.0.x server 11. Shut down the Tomcat 4.1.x server 12. Start the Tomcat 4.1.x server 13. Verify that it is running by browsing http://localhost:8080 14. Start the Apache 2.0.x server 15. Verify the connection by browsing the following:

{{{ http://localhost/examples/jsp

16. Compare the results to the following:

{{{ http://localhost:8080/examples/jsp

17. If they are the same, you have Tomcat 4.1.x talking to Apache {{{ 2.0.x.

LinuxJK (last edited 2009-09-20 23:31:25 by localhost)