Install Tomcat

This information is now maintained on my wiki http://www.mikepalmer.net/wiki/ApacheTomcatHowto.

We don't want to run Tomcat as root so I like to setup a user named tomcat before installing/running Tomcat.

  1. At a command prompt:
    groupadd tomcat
    useradd -g tomcat -c "Tomcat User" -d /usr/local/tomcat tomcat
    passwd tomca
    t
    This adds a group called tomcat to your system, a user called tomcat to your system, and changes the password for the tomcat user (set the password to whatever you like...make it good!). It also sets the home directory for the tomcat user to /usr/local/tomcat (more on that later).
  2. Now, grab the Tomcat binary package for 5.0.19 from a mirror site. The filename is tomcat-5.0.19.tar.gz
  3. Unpack it to /usr/local:
    cp -p jakarta-tomcat-5.0.19.tar.gz /usr/local/
    cd /usr/local
    tar xvzf jakarta-tomcat-5.0.19.tar.gz
    You should end up with /usr/local/jakarta-tomcat-5.0.19.
  4. Add a symbolic link for easy management:
    ln -s /usr/local/jakarta-tomcat-5.0.19 /usr/local/tomcat
    This way, you can install various versions of Tomcat and control which version is linked to /usr/local/tomcat. This makes upgrades easier.
  5. Next, set the ownership of the Tomcat directories:
    chown tomcat:tomcat /usr/local/tomcat
    chown -R tomcat:tomcat /usr/local/jakarta-tomcat-5.0.19
  6. Set CATALINA_HOME as an environment variable, pointing to /usr/local/tomcat by adding the following lines to /etc/profile:
    CATALINA_HOME=/usr/local/tomcat
    export CATALINA_HOME
  7. Verify that CATALINA_HOME is set:
    echo $CATALINA_HOME
    You should see the value /usr/local/tomcat returned. If you don't, go back through the steps until CATALINA_HOME resolves to the correct value. You will need to reload your shell so log out and back on or whatever it takes to do that.
  8. *OPTIONAL* Set your development enviroment into /etc/profile by adding the following archives to the end of your classpath from the JDK section
    CLASSPATH=......:${CATALINA_HOME}/common/lib/servlet-api.jar:${CATALINA_HOME}/common/lib/jsp-api.jar
  9. Verify that the additional archives are in your classpath
    echo $CLASSPATH
    You should see the addition to your JDK enviroments classpath returned. This will let your JDK enviroment know where to find common classes needed when compiling servlets with javac if the -classpath flag is not used.
  10. Startup Tomcat to test your installation:
    su - tomcat -c /usr/local/tomcat/bin/startup.sh
    Verify the Tomcat examples are available at http://ip-address:8080/jsp-examples and http://ip-address:8080/servlet-examples.
  11. Shutdown Tomcat until you can get the connector installed:
    su - tomcat -c /usr/local/tomcat/bin/shutdown.sh

Back to JDK Main Continue to mod_jk2