Now blogging at diego's weblog. See you over there!

update: setting up apache, tomcat, and mysql


One of the most visited entries from last year was my configuring apache 2 + tomcat 5 + mysql + jdbc access on linux and windows post. However, after a few months there was a change in the default Tomcat configuration (as well as changes in the connectors) that rendered the Tomcat/Apache connection part nearly useless. That is, it does apply to those specific versions, but no version of Tomcat after 5.0.18 (which is the one I used there) matches the description in the post, even though the Tomcat major version --5.x-- hasn't changed. Sigh. Those are the problems that open source creates sometimes, constant changes in tiny things, config or code, that break a lot of stuff without a clear reason (maybe there is a reason, but it's usually not communicated properly, or at all).

Anyway, I've recently done a new configuration using the latest tomcat, so here's an update to that post on that section. The other sections (that deal with Apache installation, MySQL and so on) have remained largely relevant.

The tomcat config

As far as tomcat itself is concerned, the main change was the configuration for the Context. My post says that you should look for the line "<Context path="" docBase="ROOT" debug="0">" which in the newer default server.xml config files doesn't exist anymore. So where does the context line go? It turns out that the new server.xml includes a default config for a Host. Within the host there's a Logger element set up. After that is where I've now included the context path. Similarly, I've added a Resource tag after the Context for the JDBC connection. Summarizing, After the Logger tag in the Host I've added the following:
<Context path="/appPath" docBase="APACHE_DIR/htdocs" debug="0" reloadable="true" crossContext="true"/>
<Resource name="jdbc/mysql"

The connector config

I'm still using JK2. The main difference is that instead of adding the connection point in I am now adding it in jk.conf (which I think is a new file in the recent versions of jk2). I added the following line at the end of jk.conf

JkMount /appPath/*.jsp ajp13

Note that "appPath" is the context that was defined above.

So, I think that's it as an update. It's not a huge difference, but judging from my experience (and from emails I keep getting on the topic) this was more than enough to complicate usage of the old instructions.

Configurations are always a problem, no matter how many HOWTOs you've got, but I hope this makes things at least a bit easier!

Posted by diego on January 26 2005 at 5:40 PM

Copyright © Diego Doval 2002-2011.
Powered by
Movable Type 4.37