Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

December 15, 2003

Tomcat 5.0 and Apache 2.0

Ah, the joys of open source software. For various reasons I'm trying to connect Apache Tomcat 5.0 to serve through Apache 2.0.

What is scuppering me is the usual open source problem that the documentation isn't keeping up with the software. Delving into the Tomcat 5 documentation is frustrating, because as soon as you click on any link relating to Apache integration (for instance the section on JK2) you are taken to the 4.0 documentation. So far, the only thing I have been able to discover with any confidence is that the intstructions for linking Tomcat 4.0 and Apache 2.0 don't work with Tomcat 5.0. But then I could have guessed that.

Anyone got any suggestions? Or should I just run Tomcat 4.1?

Posted by Andy Todd at December 15, 2003 01:18 PM

Comments

I would have to take you out for a pint if you were in australia. You couldnt be more right, tomcat 5 and jk2-2.0.43.dll (latest build) are hard to configure with no documentation WHAT SO EVER. I think the 'tomcat user group' is a good place to start. I have got answers on there concerning this before. There are some links for doing tomcat 4 but thats about it. If i get mine working I will post it on the java dev site overtop of the tomcat 4 one. Can you do the same?

cheers mate!

Posted by: Brennon on January 21, 2004 01:57 AM

I have exactly your same idea, are 2 days that I am looking documentation visiting web sites but It is very confused. No clear information how to integrate Apache 2.0 and Tomcat 5.0. I am considering to buy some commercial products at this point.

Posted by: Nazzareno on January 22, 2004 09:11 AM

I reckon I've got the connectors issue sorted.

Download the 5.0.18 binaries, and install them as normal.

The get the source. I got it from here:

http://apache.mirror.positive-internet.com/jakarta/tomcat-5/v5.0.18/src/

gunzip it, untar it, then cd to the jakarta-tomcat-5.0.18-src/jakarta-tomcat-connectors/jk/native directory.

Run buildconf.sh, then run:

./configure -with-apxs=/usr/local/apache2/bin/apxs

(or wherever your apache2 apxs is, obviously. Then you end up with a shiny new mod_jk.so

Check the BUILDING file in the jakarta-tomcat-5.0.18-src/jakarta-tomcat-connectors/jk/native directory.

I haven't tested it yet, so caveat emptor...

Posted by: Mark Henshall on February 4, 2004 12:24 PM

Ask, and the blogosphere will provide. Diego Doval posted this tutorial on connecting Apache 2, Tomcat 5 and MySQL today;

http://www.dynamicobjects.com/d2r/archives/002574.html

Blimey, PHP isn't that hard.

Posted by: Andy Todd on February 11, 2004 11:12 AM

You also might find it easier to use mod_proxy to get requests to Tomcat5 via Apache2. I've managed to get it working.

Posted by: Zach on March 12, 2004 02:37 PM

Hi I'm also trying to integrate Tomcat5 and Apache2. Its really bloody annoying. I downloaded a bundle package called Xampp which sets up a Apache server with PHP/MySQL/PEAR/CGI/PERL and am now trying to integrate it with my fully configured Tomcat5 container.

God what a pain in the ass! I've suggested to the makes of Xampp that they integrate JSP/Tomcat into their setup. But we'll have to wait for that. Also I have read that Tomcats connectors have been removed from their web site. I've also noticed that I've download a mod_jk2.so file for WinXP is this right? I thought it was suppose to be a *.dll file?

Regards - Fan

Posted by: Fan on April 25, 2004 06:56 PM

How to build a mod_jk2.so module for Apache2.0.49 and Tomcat5.0.19 on linux
Redhat 8.0
Apache is installed at: /usr/local/apache2.0.49
Login: root
# Script to Build mod_jk2.so

## 1. Install Apache2.0
## 2. Download and unzip tomcat5 source distribution.
## 3. Set the {apache_home} and {tomcat_source} environment variables.

apache_home=/usr/local/apache2.0.49
tomcat_source=/pkg-installs/tomcat/jakarta-tomcat-5.0.19-src

start_dir=.

cd ${tomcat_source}/jakarta-tomcat-connectors/jk/native2
chmod +x buildconf.sh
./buildconf.sh
./configure --with-apxs2=${apache_home}/bin/apxs
make

echo "Show location of mod_jk2.so"
find . -name "mod*jk*.so"

#libtool --finish ${apache_home}/modules

## Uncomment the following lines to install jk2 in your apache modules directory.
#echo Installing mod_jk2.so in ${apache_home}/modules
#cp ${tomcat_source}/jakarta-tomcat-connectors/jk/build/jk2/apache2/mod_jk2.so ${apache_home}/modules
#cd ${apache_home}/modules
#chmod +x mod_jk2.so

cd ${start_dir}

Posted by: Dan Riesland on April 30, 2004 12:11 AM

I finally got Tomcat 5 to work with Apache 2 on Win XP.
I will just post the basics of the config.
I will not go through the installation of Apache or Tomcat.

1. Download mod_jk2 and put it in [apache_HOME]/modules and rename it mod_jk2.so

2. Edit [apache_HOME]/conf/httpd.conf file and add:

LoadModule jk2_module modules/mod_jk2.so

to the LoadModules section.

3. Create workers2.properties in the [apache_HOME]/conf folder and add:

[shm]
file=C:\Apache2\logs\jk2.shm
size=1048576
# socket channel
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# worker for the connector
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/jsp-examples/*]
[uri:/tomcat-docs/*]

Edit the paths to reflect your installation

4. Edit [tomcat_HOME]/conf/jk.properties and add:

handler.list=channelSocket,request
channelSocket.port=8009
channelSocket.address=127.0.0.1

5. OPen [tomcat_HOME]/conf/server.xml and add:

< Context path="" docBase="c:/[apache_HOME]/htdocs" debug="0" reloadable="true" crossContext="true"/>

6. Stop both Tomcat and Apache

7. Restart Tomcat and test Tomcat by going to http://localhost:8080/jsp-examples
If this works:

8. Start apache and go to http://localhost/jsp-examples
If this works, GREAT, you've got it.
If it doesn't? Good luck. The documentation for this implementation sux.
You can check these to url. I used both:

http://www.dynamicobjects.com/d2r/archives/002574.html

http://www.10xsoftware.com/products/jewelbox_guides/samples/apache/win2k/Integrating%20Apache%20with%20Tomcat%20for%20Windows.html

Posted by: Greet Rufus on May 23, 2004 03:47 PM

I am very happy with your contribution... It really helped me a lot. I was struggling for last 72 hours, but within no time it started working

Posted by: Sanjay on July 7, 2004 08:01 AM

your guideline really helps, thank youuuuuuuuuuuu!!!!!

Posted by: jwangk on July 22, 2004 12:37 PM

Thank you very much for this guideline...
it works for Tomcat 3.* and 4, too.

Posted by: LevinBeicht on August 30, 2004 01:41 PM

Hi David (Greet Rufus)....its gr8..works fine...So thankfull to U on this....Thank U (1 mil)..

Posted by: Raj on October 29, 2004 02:14 PM

exactly where do you post the statment in step 5? I've tried everywhere in the server.xml file, and can't seem to get it to work.

Thanks

Posted by: almeister on November 9, 2004 11:56 AM