Jan 11, 2012

Tomcat Configuration

For those keeping track, I have been playing with Tomcat. And I have mentioned the lack of useful tutorials out there. So here is one I made to (hopefully) fill in the gap! If you have any questions just ask away in the comments!

What you need:

  • Apache Tomcat
  • This guide was done with CentOS, but should be applicable to other Unix-based distributions

Summary:

This guide will take you through some steps to ensure Tomcat just works. I am trying to be as thorough as possible so some of these steps may not be applicable to you.

Here we go....

  1. First, you have to install Tomcat5. I just use the CentOS repository since that is the nice & easy way to get the latest security patches and fixes. Of course, purists will recommend you build from source. Each to their own; if you choose to do it my way just enter the following into the command-prompt:

    sudo yum install tomcat5
     
  2. Find out which version of Java you are running (so we can set up our variables)

  3. /usr/sbin/alternatives --display java

    Our system is configured to use /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

  4. Now we need to edit the Tomcat5 configuration file to use our Java implementation. Edit the file /etc/tomcat5/tomcat5.conf with your own values:

    # you could also override JAVA_HOME here
    # Where your java installation lives
    JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk/"
    # Time to wait in seconds, before killing process
    # Lower this value for testing to stop you waiting ages
    SHUTDOWN_WAIT=10
    # Connector port is 8080 for this tomcat5 instance
    # Need to change this in server.xml as well
    CONNECTOR_PORT=8080


  5. Edit /etc/tomcat5/server.xml file with your desired configuration

  6. Start Tomcat5 through the following commands:

    sudo /etc/init.d/tomcat5 start
    #To start tomcat on reboot run the following
    sudo chkconfig tomcat5 on --level 2,3,5

References:

  • OpenBD guide to running Tomcat (geared to their app)
  • David Ghedini's blog offers a great overview of this topic

No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!