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,
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:
>startup -jkconfto generate the mod_jk.conf file.
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:
Include TOMCAT_HOME/conf/jk/mod_jk.confat the end of the http.conf file.
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: