How to Install Java Tomcat Apache and Centos 5

Scenario / Question:

How do I install Tomcat on Centos

Solution / Answer:

In order to install Tomcat on Centos you first need to install Java. Both free and non-free packages are required for the installation. The non-free packages do not cost money however you must download them directly from Sun and agree to the license terms.

Install Build Packages

# yum install rpm-build gcc-java jpackage-utils libXp

Download Java files:

Make a Directory to store the Java files:

# mkdir /opt/Java

Download needed files to Java directory we created:

# cd /opt/Java
# wget http://mirrors.sunsite.dk/jpackage/1.6/generic/non-free/SRPMS/jta-1.0.1-0.b.4jpp.nosrc.rpm
# wget http://mirrors.sunsite.dk/jpackage/5.0/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.15-1jpp.nosrc.rpm

Download 2 needed files from Sun:

Go to http://java.sun.com/products/archive/ and half way down the page you will see JDK/JRE – 5.0 to the right of it in the drop down box select “5.0 Update 15″ and hit GO. Select “Download JDK” and next page select platform: linux and download the file jdk-1_5_0_15-linux-i586.bin to Directory /opt/Java

Go to http://java.sun.com/products/jta/ and select “Class Files 1.0.1B” Download. Download file to Directory /opt/Java

Install Build RPM Java files:

Copy files downloaded from Sun site to /usr/src/redhat/SOURCES :

# cp /opt/Java/jta-1_0_1B-classes.zip /usr/src/redhat/SOURCES/
# cp /opt/Java/jdk-1_5_0_15-linux-i586.bin /usr/src/redhat/SOURCES/

Build the RPM files and install:

rebuild — installs the named source package, and does a prep, compile and install. In addition, –rebuild builds new binary package

# rpmbuild --rebuild /opt/Java/java-1.5.0-sun-1.5.0.15-1jpp.nosrc.rpm
# rpm -Uvh /usr/src/redhat/RPMS/i586/java-1.5.0-sun-1.5.0.15-1jpp.i586.rpm
# rpm -Uvh /usr/src/redhat/RPMS/i586/java-1.5.0-sun-devel-1.5.0.15-1jpp.i586.rpm
#rpmbuild --rebuild --without javadoc /opt/Java/jta-1.0.1-0.b.4jpp.nosrc.rpm

# rpm -Uvh /usr/src/redhat/RPMS/noarch/jta-1.0.1-0.b.4jpp.noarch.rpm

Install Tomcat Apache:

Install Tomcat Apache using yum:

# yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps

If you get an error:

***Error Missing Dependency: /usr/bin/rebuild-security-providers is needed by package java-1.4.2-gcj-compat
1. Remove jpackage-utils: rpm -e jpackage-utils –nodeps
2. Disable the JPackage repo
3. Install from standard repos: yum install jpackage-utils

Start Tomcat and Set to Start on Boot

Start Tomcat:

# service tomcat5 restart

Set to Start on Boot:

# chkconfig tomcat5 on
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Fabio Milano has written 79 articles for us. Fabio Milano is a certified RHCE, MCP, and CFOI. He runs an IT consulting and services company called RDS Support inc. Website:http://www.rdssupport.com
The information provided is for educational purposes only. All content including links and comments is provided "as is" with no warranty, expressed or implied. Use is at your own risk and you are solely responsible for what you do with it.

6 Comments so far

  1. Mr Dobalina on June 12th, 2009

    There is a typo in this how-to. The line after “Install Build Packages” should read:
    # yum install rpm-build gcc-java jpackage-utils libXt

  2. Lee on January 10th, 2010

    The install ran without errors but when I do java -version, OpenJDK still shows and no Sun Java. How do I set the Home path and such?

  3. Jack F on March 22nd, 2010

    Worked perfectly. Thanks!

  4. Jerlando on December 21st, 2010

    Usefull tutorial!

  5. manoj jasawat on April 12th, 2011

    this is very usefull for installation …..

    thanks…

  6. Sandy on June 26th, 2011

    My VPS Configuration
    OS: centos-5-x86_64
    VPS Platform: OpenVZ
    HDD : 50 GB
    Ram : 1 GB

    I am trying to install 1 software on my VPS. But java is giving me some problem

    [property] java.io.IOException: Cannot run program “/bin/env”: java.io.IOException: error=12, Cannot allocate memory

    So then I am tried to allocate heap memory to JVM by using command
    # java -Xms128m -Xmx128m DoRunTime

    It will give such type of error

    Exception in thread “DoRunTime” java.lang.NoClassDefFoundError: DoRunTime
    Caused by: java.lang.ClassNotFoundException: DoRunTime

    I have set my path as follows,
    JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64

    PATH=$PATH:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin

    I am also tried simple program of JAVA & Its working properly.

    I think the problem is in JVM heap memory.

    Is there any need of creating partition???

    # free -m
    total used free shared buffers cached
    Mem: 1024 23 1000 0 0 0
    -/ buffers/cache: 23 1000
    Swap: 0 0 0

    What should i do??
    plz reply

Leave a reply