April 23, 2014

Installing Tomcat 6 on CentOS 5.5 Tutorial

Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process.

So before we start just some general house keeping. The base CentOS 5.5 server hostname and IP address that we’ll be using in this tutorial:

* www.how2centos.com (IP 10.0.0.3)

The Tomcat 6 Server will eventually be available on http://www.how2centos.com:8080

The assumption, for this Tomcat 6 and CentOS 5.5 tutorial, is that you are running as root and have a medium understanding of the software required but if you’re Awesome that’s good enough.

Install Yum Priorities

For a brief overview on and how to configure Yum Priorities you can follow the instructions outlined in our Install YUM Priorities on CentOS tutorial.

# yum install yum-priorities

Install the EPEL i386 YUM Repository

# rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install the RPMForge i386 YUM Repository

# rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Install the JPackage Project repository

# cd /etc/yum.repos.d/
# wget http://jpackage.org/jpackage50.repo

Install Java

We just used the openjdk that available via the repositories but if you prefer Sun JDK the download it and install it.

yum install java

Install Tomcat6

# yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps

Add in JAVA_HOME under the CATALINA_TMPDIR reference

# vi /usr/share/tomcat6/conf/tomcat6.conf

1
JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/"

Start the Tomcat 6 service

# service tomcat6 start

Browser to your newly installed Tomcat6 Server (remember port 8080)

http://www.how2centos.com:8080

  • Noone

    you may encounter a “Missing Dependency: /usr/bin/rebuild-security-providers” error when attempting the final yum install tomcat6.

    The problem & solution are documented here http://plone.lucidsolutions.co.nz/linux/centos/jpackage-jpackage-utils-compatibility-for-centos-5.x.

    The workaround is:
    rpm -Uvh http://plone.lucidsolutions.co.nz/linux/centos/images/jpackage-utils-compat-el5-0.0.1-1.noarch.rpm

  • Anon

    Did not work for me :-(

  • Anon

    Did not work for me :-(

    Update: In particular tomcat failed to start ( after running alternatives ) with:
    Class loader creation threw exception java.lang.NoClassDefFoundError: javax.management.MBeanServerFactory
    Something is still missing it seems

  • Hcb

    worked like a charm for me . Thanks Hendrik Beukes

  • Bschreierb

    It works perfectly!! thanks a lot!!

  • alex

    In Centos 5.6, when the next error:nnMissing Dependency: /usr/bin/rebuild-security-providers is needed by package java-1.4.2-gcj-compat-1.4.2.0-40jpp.115.i386nnthis solve this problem;nnrpm -i http://candrews.integralblue.com/wp-content/uploads/2009/07/jpackage-utils-compat-el5-0.0.1-1.noarch.rpm

  • http://twitter.com/gurustuji gurustuji

    After trying to work with the CentOS packaged version of Tomcat, I’ve realized that I’m much better off getting a nice vanilla install from Apache and installing it myself. It’s unclear to me why packagers choose to alter or remove functionality from the software they package, but they have with Tomcat (the start jdpa option is missing, for example), and it’s a giant pain in the posterior to deal with.

    I prefer to live in a world where Tomcat is installed the same on every machine I look at, than a world in which every app on a specific CentOS box is installed the same but those apps are also missing key features.

  • Ajith

    how can Run Tomcat on port 80??
     

  • Rohitpatel(linux system admin)

    solid data h bhai gud 1 ………..enjoyed installing it on VPS server machine to one of my client

  • Redlofa
  • Joe Lemaire

    First off, thanks for this article!

    Secondly, I had an issue where tomcat installed successfully (ie no errors) but I couldn’t access http://server:8080.  The service wouldn’t stop, only start, and I was seeing errors like this in the /var/log/tomcat6/catalina.out:

    SEVERE: Class loader creation threw exception
    java.lang.NoClassDefFoundError: javax.management.MBeanServerFactory
       at org.apache.catalina.startup.Bootstrap.createClassLoader(Bootstrap.java:179)
       at org.apache.catalina.startup.Bootstrap.initClassLoaders(Bootstrap.java:92)
       at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:207)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:391)

    The resolution was to make sure that the JAVA_HOME directory was set correctly.  To do so:

    $ vim /usr/share/tomcat6/conf/tomcat6.conf

    # Add in JAVA_HOME under the CATALINA_TMPDIR reference
    JAVA_HOME=”/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/”

    $ service tomcat6 restart

    I was then able to get to http://server:8080!

  • Anonymous

    Thank you for the feedback. I have amended the document with your suggestion.

  • http://www.facebook.com/rastasaus Allen Williams

    …like a charm! except i have 64bit centos so i had to use some common cents to change a few things, including java_home which i found at /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 … also be sure to install repositories for 64bit also.

  • Jhony Maseto

     thanks a lot

  • http://www.facebook.com/craigstylesnewton Craig Newton

    Worked wonders for me, thanks!

    Just had to change:
    JAVA_HOME=”/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/”

    To

    JAVA_HOME=”/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre”

    How2Centos Rocks!

  • ExiledHammer

    A big thank you. After about 10 aborted attempts this was the first tutorial that worked! Highly recommended.