Installing Tomcat5.5 and integrating it with Apache 1.3

Wouter van Reeven 20
0 0
Read Time:4 Minute, 3 Second

Recently I have upgraded my web server at home to the latest version of Tomcat (version 5.5.7 at the moment of this writing). Time to document my steps a bit. Please note this document focusses on installing Tomcat 5.5 on a Debian Woody Linux machine, but the steps shouldn’t differ much on other Linux systems or (perhaps) even a Windows system.

As can be seen on the Tomcat Setup document page, Tomcat 5.5 is intended to be used with the J2SE 5 JRE. One version of this JRE can be downloaded from the Sun Java 2 Platform Standard Edition 5.0 download page. I downloaded the JDK and installed it into the /usr/local directory of my webserver using the commands

# chmod 755 jdk-1_5_0_01-linux-i586.bin

and

# ./jdk-1_5_0_01-linux-i586.bin

Please note this needs to be done as root user, since “normal” users don’t have write permissions in the /usr/local directory. Next, I set the JAVA_HOME environmental variable in the root user’s .profile file like this:

export JAVA_HOME=/usr/local/jdk1.5.0_01

To make the variable effective, I logged out and back in again.
I then downloaded the Tomcat binary version and installed it into the /usr/local directory as follows:

# tar zxf jakarta-tomcat-5.5.7.tar.gz

This created the directory /usr/local/jakarta-tomcat-5.5.7 and this is where everything Tomcat related resides. Both Tomcat itself and this document will refer to this directory as $CATALINA_HOME. To start Tomcat, I issued

# cd jakarta-tomcat-5.5.7/bin
# ./startup.sh
# tail -f /usr/local/jakarta-tomcat-5.5.7/logs/catalina.out

The last command makes sure the contents of the catalina.out log file are displayed on the screen and any new content in the file is shown as well. Once the line INFO: Server startup in 22292 ms was displayed, I knew Tomcat 5.5 was started up. To verify, I browsed to http://www:8080 to see the Tomcat 5.5 welcome screen.:

To add a web application, I needed to do two things. First of all, the web application needs to be placed in the $CATALINA_HOME/webapps directory. Second, a <Context> element needs to be added to $CATALINA_HOME/conf/server.xml file. Since I wanted to add a web application called Test, I would place it in the $CATALINA_HOME/webapps/Test directory and add this line

<Context path="/Test" docBase="Test" debug="99" reloadable="true"/>

to the $CATALINA_HOME/conf/server.xml file, just above the </Host> statement nearly at the bottom of the file. In case I would have liked to deploy my web application in a war file, I simply had to put the war file in the $CATALINA_HOME/webapps directory and place the war file name in the docBase attribute of the Context element in the server.xml file. Then I restarted Tomcat afterwards as root user like this

# cd /usr/local/jakarta-tomcat-5.5.7/bin
# ./shutdown.sh
# ./startup.sh

To access the Test web application, I had to browse to http://www:8080/Test/ but I really wanted to be able to browse to http://www/Test/. One way of doing this is modifying the Tomcat server config file to make Tomcat listen on port 80 instead of 8080 but that would of course interfere with the Apache web server listening on that port. Fortunately it is possible to transparantly forward all incoming requests for the Test web application from Apache to Tomcat using the Tomcat Connector which can be found on The Apache Jakarta Tomcat Connector.
The Tomcat Connector website provides binary versions for some Linux distributions and other operating systems. Unfortunately, Debian isn’t one of them, so I had to compile the module myself. For this, I downloaded the source package of version 1.28 which was the latest version of the Tomcat Connector at the time of this writing. To be able to build the Tomcat Connector module, the Apache Extension Tool apxs is needed. On Debian, this is provided by the apache-dev package, so I made sure it was installed. To build the connector, ungzip and untar the source tar ball and I used the configure and make commands like this:

# tar zxf jakarta-tomcat-connectors-1.2.8-src.tar.gz
# cd jakarta-tomcat-connectors-1.2.8-src/jk/native
# ./configure --with-apxs=/usr/bin/apxs
# make

After all of this, the Tomcat Connector module could be found in the apache-1.3 subdir of the directory these commands were executed from. To install the connector module, I issued as root user

# cp apache-1.3/mod_jk.so.0.0.0 /usr/lib/apache/1.3/

ln -s mod_jk.so.0.0.0 mod_jk.so

Please note that the path to the apache lib directory (/usr/lib/apache/1.3 in this case) may be different on different Linuxes or other operating systems. Finally, to make sure the correct paths are mapped from Apache to Tomcat, I added these lines to the Apache config file httpd.conf:

LoadModule jk_module /usr/lib/apache/1.3/mod_jk.so
<ifmodule mod_jk.c>
JkWorkersFile /usr/local/jakarta-tomcat-5.5.7/jk/workers.properties
JkLogFile /etc/apache/logs/mod_jk.log
JkLogLevel info
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount /Test/*.jsp worker1
JkMount /Test/* worker1
</ifmodule mod_jk.c>

and created the Tomcat Connector config file /usr/local/jakarta-tomcat-5.5.7/jk/workers.properties like this:

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

Next, I restarted Apache and browsed to http://www/Test/ and got to see my web application. That’s it!

About Post Author

Wouter van Reeven

Wouter is Java consultant at AMIS
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

20 thoughts on “Installing Tomcat5.5 and integrating it with Apache 1.3

  1. I need to deploy Tomcat as a specific user for dspace. Should this be necessary?
    How would I do it.

  2. i have install
    tomcat5.5 in c:/ and
    j2sdk1.4.2_08 in C:/Program Files/Apache Software Foundation/Tomcat 5.5
    set JAVA_HOME=C:/program files/Java/jdk1.5.0
    TOMCAT_HOME=C:/Program Files/Apache Software Foundation/Tomcat 5.5
    Then i started tomcat
    after that i start IE using http://localhost:8080/
    but this shows page does not display
    What is the problem? If anyone can, plz help.

  3. I have configured default docBase to directory where my application resides.
    like

    But my tomcat5.5 installation is totally in other directory. After starting the tomcat, now connecting to tomcat results in failure of picking up my docbase instead it use its own docbase.
    plz help.

  4. i have install
    tomcat5.5 in c:/ and
    j2sdk1.4.2_08 in C:/Program Files/Apache Software Foundation/Tomcat 5.5
    set JAVA_HOME=j2sdk1.4.2_08
    and CATALINA_HOME=C:/Program Files/Apache Software Foundation/Tomcat 5.5
    TOMCAT_HOME=C:/Program Files/Apache Software Foundation/Tomcat 5.5
    Then i started tomcat
    after that i start IE using http://localhost:8080/
    but this shows page does not display
    What is the problem ,
    any help will be appreciated.

    sanju

  5. Hi Lavan,

    Edit the file

    /conf/tomcat-users.xml

    and add a line like this

    Save the file and restart Tomcat. Now you should be able to login as user wouter with password wouter. Unfortunately, there is no other way of configuring users and roles in Tomcat. As the Tomcat docs put it:

    “Administering the information in the users file is the responsibility of your application. Tomcat does not provide any built-in capabilities to maintain users and roles.”

    HTH, Wouter

  6. yo guys ,
    i am not abel to get the manager or the admin page on apache- tomcat5i work on linux, i did not give it any password or any thing when i installed just installed the .tar.gz file and just got the index.jsp running , how come it asks me for the user name and password…. plz can anyone help me .
    lavan

  7. I’m setting up tomcat 5.5 to work with apache 2 on a windows xp machine. can someone please point me to a good resource on updated info? i’ve scoured the net and even tomcats own site and it seems that no one has a simple solution. thanks in advance feel free to email me at kewlken6@hotmail.com

  8. Thanks mate – worked like a charm first go! ONly difference is that I was using Java 1.4.2 with the latest version of Tomcat.

  9. Nice tutorial.
    I follow everything on this tutorial but I am getting a 404 error. Under Tomcat application is working great.
    I deploy the app via a .war file as described.
    I am trying to map the opencms CMS under apache.

    Any suggestions?

  10. Do you have instructions for Installing Tomcat5.5 and integrating it with Apache 1.3
    for windows 2000/XP ? I really appreciate it. Thanks

  11. You don’t need to do anything other than to drop the war file to deploy a web application. Also when you create a directory under webapps with proper structure like WEB-INF and has WEB-INF/web.xml then it is automatically recognized as an web application. No further changes necessary

  12. You don’t need to do anything other than to drop the war file to deploy a web application. Also when you create a directory under webapps with proper structure like WEB-INF and has WEB-INF/web.xml then it is automatically recognized as an web application. No further changes necessary.

Comments are closed.

Next Post

FireFox on the march - 29%! : Browser Statistics from the AMIS Technology Weblog

Our weblog started last July. Since then we had over 250000 hits from over 45000 different IP-addresses. Last night, I sat down to do a comparison between the various browsers used to access our Technology Weblog. And I also looked at the trends since July. It is interesting to see […]
%d bloggers like this: