Tomcat 4.1.x and Apache 2.0.x on Windows/2000 with mod_jk.dll
One of the nice benefits of using the same servers on both platforms is that the configuration (except for directory delimiters) is the same. This eases the system administration burden.
%APACHE_HOME% refers to the root directory of the Apache 2.0.xx installation (which is C:\Apache2 for this machine). %CATALINA_HOME% refers to the root directory of the Tomcat 4.1.xx installation (which is C:\Tomcat for this machine).
I realize that the Windows default is to place all programs in { { { %SystemDrive%\Program Files } } }. Personally, I think putting a command delimiter (space) in the name of a directory or file is not very useful. Windows/2000 doesn't even handle this issue in a consistent manner. In short, I recommend to NOT place the Apache and Tomcat servers in Program Files.
The mod_jk.dll used in writing this documentation was downloaded from the following location:
http://munkeh.ehpg.net:8080//apache/jakarta/tomcat-connectors/jk/binaries/win32/
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.dll to %APACHE_HOME%/modules
2. Make sure mod_jk.dll can be read by System
3. Create a workers.properties file with the following information
{{{ #
# Where some things are located
#
workers.tomcat_home=C:\Tomcat
workers.java_home=C:\j2sdk1.4.2
workers.apache_log=C:\Apache2\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 NOTE: Change the following to reflect your installation:
- workers.tomcat_home - where your Tomcat 4.1.x server is installed
- workers.java_home - where your Java SDK is installed
- workers.apache_log - where your Apache 2.0.x logs are written to
4. Place this file in %APACHE_HOME%\conf
5. Make sure this file is readable by System
6. Add the following in %APACHE_HOME%\conf\httpd.conf to load
{{{ mod_jk.so
#
# Adding mod_jk
#
LoadModule jk_module modules\mod_jk.dll 7. Add the following in %APACHE_HOME%\conf\httpd.conf to take care of {{{ mod_jk housekeeping
- # # Housekeeping stuff # # Where to find workers.properties #
JkWorkersFile C:/Apache2/conf/workers.properties # # Where to put jk logs #
JkLogFile C:/Appache2/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"
- }}}
NOTE: Replace { { { C:/Apache2 } } } 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/ "C:/Tomcat/webapps/examples/" NOTE: Replace { { { C:/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
http://localhost/examples/jsp/dates/date.jsp http://localhost/examples/servlets/ http://localhost/examples/servlet/HelloWorldExample }}}
16. Compare the results to the following:
{{{ http://localhost:8080/examples/jsp
http://localhost:8080/examples/jsp/dates/date.jsp http://localhost:8080/examples/servlets/ http://localhost:8080/examples/servlet/HelloWorldExample }}}
17. If they are the same, you have Tomcat 4.1.x talking to Apache {{{ 2.0.x.
- }}}