(Edit 3/6/2006: This is wrong, in that it still uses mod_jk2. This is not a how-to for mod_jk. Rjae Easton has a good post on getting mod_jk working that you should head over to if that's what you need. - Cory)I don't really anticipate this taking that long, but figured I would document it out since I can't
find much documentation on this.
So the basic premise is that I have a
Gentoo Linux box that I am hosting some sites on. I want to get Tomcat up and running so I can do some dynamic content with it. I already have Apache running, which I installed by doing the very difficult:
emerge apache2I also had to do some config changes because I am running virtual hosts. I made sure that all this was fat and happy (which it was), so Apache is good.
Next I installed Tomcat. This also was just:
emerge tomcatwhich hummed along quite nicely and plunked it on there. Doing a
netstat -a showed me that it was running and listening, and browsing to localhost:8080 showed me the nice Tomcat install page.
Now, the final step is to get Apache to send my jsp's to Tomcat for processing. Much of the documentation I found revolved around mod_jk2 which has been deprecated for mod_jk. Of course, nobody really talks about mod_jk (which is why you are reading this!).
I started with a document called
HOWTO: Apache2 and Tomcat5 from the Gentoo Wiki. The big difference was in mod_jk, which I built from source using the directions from
this article on something called SnipSnap. My workers.conf was nearly identical to the workers.properties listed in the HOWTO article. For the apache2.conf, I moved it over to my vhosts/vhosts.conf file, which looks basically like:
################# Named VirtualHosts
NameVirtualHost *:80
LoadModule jk2_module extramodules/mod_jk2.so
JkSet config.file /etc/apache2/conf/workers2.conf
<VirtualHost *:80>
ServerName www.mysite1.com
ServerAlias mysite1.com *.mysite1.com
DocumentRoot /var/www/localhost/htdocs
<Location /*.jsp>
JkUriSet worker ajp13:localhost:8009
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite2.com
ServerAlias mysite2.com *.mysite2.com
DocumentRoot /var/www/mysite2/htdocs
<Directory /var/www/mysite2/htdocs>
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
At that's where I'm at. Both of my sites are still up, and sending a request to mysite1.com/test.jsp (a simple jsp) appears to do something, but it isn't quite working yet. Right now the page just sits there and spins, but I don't see anything funky in the server logs to help track it down. I'll try some more tomorrow.
UPDATE: So it turns out that the only thing I had wrong was my workers2.conf file. I had:
[channel.socket:localhost:8009]
port=8009
host=mysite1.com
type=ajp13
which was resolving the site name to the public IP address, which, of course, is firewalled and had port 8009 blocked. Changing it to:
[channel.socket:localhost:8009]
port=8009
host=localhost
type=ajp13
fixed it, and all is well with the site! Yea, no day 2 necessary!