shesafish

| Home | Outline | Stylesheet insipired by CSS Colouring Book |

How to Run Tomcat with Apache on Win32

I had a devil of a time getting Tomcat and Apache to run together on my Win32 machine. I am writing this down for myself (for future reference, I do not want to go through this again). If anyone else can benefit from this article, maybe it was worth the effort. If you have any questions or notice information that was left out, please let me know.

I already had Apache installed on my PC. I installed Tomcat months later, and was unable to get any jsp pages to render correctly. After some research,

  1. Uninstalled Apache, deleted directory structure.
  2. Uninstalled Tomcat, deleted %CATALINA_HOME% environment variable. (Some people name their environment variable %TOMCAT_HOME% instead, both names are acceptable).
  3. Installed Apache (as a service, left it running). [Apache version 1.x]
  4. Installed Tomcat (as a regular program). [Tomcat version 3.x]

At this point I had a clean install of Apache and Tomcat. Apache was running (as a service) and Tomcat was not running. Note: in this scenario I discovered that I had to use a version of Apache that was earlier than 2.0. I cannot remember the exact version I used, 1.x. Similarly, I discovered I had to use a version of Tomcat eariler than 4.0. Again, I cannot remember the version I used, 3.x. [Todo: fill in why these versions were required. I think it had to do with mod_jk not being compatible with Apache 2.x and above, Tomcat 4.x and above.]

Next I had to choose a method to "glue" the Apache web server to the Tomcat servlet engine (sometimes these are called "connectors"). I chose the mod_jk dll. (Todo: provide a link to the mod_jk.dll for download. Also list alternative "glue" methods). I located and downloaded mod_jk.dll into the %APACHE_HOME%/modules directory.

Next I had to start Tomcat with a special argument. This argument instructed Tomcat to generate a mod_jk.conf file (for more info see Enabling Tomcat's Apache Auto-Config). This is what I did:

  1. Opened a console window, changed the current directory to %TOMCAT_HOME%/bin.
  2. Started Tomcat at command line: >startup -jkconf to generate the mod_jk.conf file.
  3. Stopped Tomcat.

Now Apache had to be told to look for this mod_jk.conf file upon startup. I stopped Apache and edited its http.conf file (for more information see Configure Apache to use mod_jk). This is what I did:

  1. Added a line Include TOMCAT_HOME/conf/jk/mod_jk.conf at the end of the http.conf file.
  2. Restarted Apache.

At this point it was time to test. I opened a browser and typed in this URL, hoping to see the Tomcat jsp examples in action: http://localhost/examples/jsp/index.html. I was able to see the examples. Success!

Next I wanted to see my jsp files in action. I pointed the browser to http://localhost/rigg/jsp/index.html. It failed with a 404 "page not found". I looked in the Apache logs (Start->Programs->Apache->Review Server Log files). I saw one message that looked interesting: "File does not exist C:\Program FIles\Apache Group\Apache\htdocs\rigg\index.htm". Aha! Apache was looking in the wrong place for my Rigg index page. Apache needs to forward requests for Rigg pages to Tomcat.

 


Links used in writing this article:

Apache and Tomcat configuration on Win32 systems using the AJP connector (do not use WARP on Win32)

http://atlassw1.phy.bnl.gov/jakarta-tomcat/mod_jk-howto.html

http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.3/bin/win32/i386/

A Beginner's Guide to Tomcat4/JSP

Apache Jakarta-Tomcat

Comment: