Howto install Tomcat 5 on CentOS 4

July 31st, 2007 , 8:04

Howto install tomcat 5 on CentOS 4

This has been taken from serral online instruction and combinded with pritical IT Works 🙂

This howto is assuming that you have a working, minimal installation of CentOS. I will repeat that because if not properly understood it will cause you lots of headaches later. A MINIMAL installation of CentOS. This means that when you are doing your installation, you should scroll to the bottom and check that pretty little box that says “minimal” so that only the bare essentials are installed. We will let yum take care of the rest.

title=”Setting_up_jpackage.org_Enviroment” name=”Setting_up_jpackage.org_Enviroment”>

Setting up Enviroment


   * Install 'jpackage-utils' (if not already in your system)

   * Install at least one JDK

   * Subscribe your system to a repository and install the package you want (dependencies will be brought in automatically)


Most Linux distributions now ship with a jpackage-utils RPM installed. If yours doesn’t, you can obtain this RPM using Repoview or the JPackage repository browser. YOU MUST HAVE A ‘jpackage-utils’ RPM INSTALLED ON YOUR SYSTEM BEFORE INSTALLING A JDK. JDK

Due to different licensing conditions, we only provide nosrc RPMS for the JDKs, or a ‘-compat’ RPM for the Sun JDKs. BEA and IBM provide us with the specifications for their JDKs RPMs, which are JPP compliant. We make them available as nosrc RPMs. The RPM on the Sun web site requires that a corresponding ‘-compat’ RPM from JPackage be installed to become compatible, or alternatively one can also rebuild a nosrc RPM for it.


ATTENTION: Please install (at least) _both_ the java-<version>-<provider> _and_ the java-<version>-<provider>-devel for a complete SDK.

(the ‘java-<version>-sun-compat’ provides everything for the Sun JDK case, so there is no -devel). Notes

If the -compat RPM for the latest Sun release is not yet available, you can request an update via the mailing list.

If the current Sun JDK is not yet packaged, you can find archived releases here.

For information on building one of the nosrc JDK RPMs from either Sun, BEA or IBM, please see Rebuilding nosrc RPMs Installing the Sun JDK using the ‘-compat’ method

This step is only necessary if you want to avoid rebuilding the nosrc JDK RPM. Please note that rebuilding the nosrc RPM is the preferred method of obtaining a JPackage JDK.

repo setup

The first thing that we have to do is set up out yum repositories so that we can find the packages to be downloaded. The jpackage repository makes this very easy and we will install this one first. All of the repositories are located in the /etc/yum.repos.d directory. To install the repository for jpackage, which contains all of the java goodies, simply:

cd /etc/yum.repos.dwget -P /etc/yum.repos.d

Edit the jpackage.repo file you retrieved and enable the repositories appropriate to your distribution. In the case of CentOS I set
enabled=1 on the jpackage-rhel sections.

The JPackage RPMs are digitally signed using a GPG key, import their key into your RPM keyring

rpm –import

Before adding new stuff make shoure your installed rpms are up to date

yum update

Get the jdk

Next, since Sun does not make available its jdk via yum, you have to go to the sun site and download it. If you point your browser over to:

     Get the Sun JDK 5.0 from:
     by choosing the "JDK 5.0 Update N" "Download" button, and then choosing "RPM in self-extracting file" for Linux on the page that displays after pressing the button.

     Important: Do NOT install the "Linux x64" version of the SDK.
     If you prefer the older Java 1.4.2 SDK, get it from:
     by choosing the "Download J2SE SDK" link and from there the "RPM in self-extracting file" for Linux.

You can download the one you see fit. I downloaded JDK 5.0 Update 12, which at the time of this howto was the current one. When you see the Sun download page, accept the agreement and pick the “Linux RPM in self-extracting file” (the one that ends in rpm.bin).

When your Sun JDK Linux RPM self-extracting file finally arrives you need to execute it, since it is a shell script. It contains the license agreement and the compressed RPM package with Sun JDK. It will ask you if you agree to the long license. Say yes, then it will uncompress the RPM with JDK, and then it will install it. To run it do:

chmod 755 jdk-1_5_0_12-linux-i586-rpm.bin

Unfortunately, the Sun RPM package puts files in different locations than the ones required by CentOS. After running the script you will see a new directory /usr/java/jdk1.5.0_07 with JDK files. Note that the actual RPM is left in the directory where you ran the Sun’s jdk-1_5_0_07-linux-i586-rpm.bin script, however, you do not need to process the RPM, since script already did it.

You may, however, use the RPM package if you want to install the JDK on another machine or if you erased the JDK at some point with a the RPM’s rpm -e jdk-1.5.0_07-fcs command. Now, we are ready to install the SUN JDK compatibility RPM from the


Install compatibility RPM

Install java-1.4.2-sun-compat or java-1.5.0-sun-compat, download it your self as the yum install tends to pick up the wrong version.

Download and install the appropriate -compat RPM from JPackage at:

Make sure to match the version of the -compat package to the SDK you’ve installed in the first step. The -compat RPM requires that the RPM self-extracting file from Sun be used in the previous step, not the plain (non-RPM) one.

 For instance, for a Sun SDK 1.5.0_12 you should get:
 and for a Sun SDK 1.4.2_12 you should use:
rpm -ivh java-1.5.0-sun-compat-

This will create a bunch of links in the /etc/alternatives and /usr/lib/jvm directories and others to the /usr/java/jdk1.5.0_07 directory where the Sun JDK distribution resides. To check which files were affected do:

rpm -q -l java-1.5.0-sun-compat

Check if the Sun JDK is really a default by doing:

java -version

If you get:

java version “1.4.2”
gij (GNU libgcj) version 4.1.1 20060525 (Red Hat 4.1.1-1)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A

(or similar) then something did NOT work. If you get:

java version “1.5.0_07″Java(TM) 2 Runtime Environment,
Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

then the Sun JDK is your default. You can use alternatives to check (or change) the default JDK by:

alternatives –config java

Please read the man page for alternatives:

man alternatives

It should show something like:

There are 2 programs which provide ’java’.

Selection Command
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2 /usr/lib/jvm/jre-1.5.0-sun/bin/java

Enter to keep the current selection[+], or type selection number:

Hit [Enter] key if you want Sun JDK to be a default, or enter 1 if you want to
change back to GNU Java.

Now, there will be times, when you want to get rid of Sun JDK and its entries for alternatives. DO NOT TOUCH THESE LINKS WITH YOUR BARE HANDS. Use yum to uninstall the JPackage Java compatibility package first and then erase the Sun JDK with rpm:

yum erase java-1.5.0-sun-compat
rpm -e jdk-1.5.0_07-fcs

Sometimes yum breaks. A popular situation is when you used rpm to install some package (or the package was installed with an install (older package is kept) rather than an update (older package is removed). In this case, yum gets confused with dependencies and complains, and it does not want to install a package. To see if this is a case (as it was when installing all of this), list all the installed rpm packages for some package name with a command:

bgcolor = “#CCCCCC” rpm -qa | grep “java”

for example. If you see two versions of the same rpm, just erase the old one. Use the

rpm -e full_package_name_with_version

(but skip the .rpm) and then try yum update or yum install again. I am telling you this, since we will definitely have more javas and compats coming, and the mess happens. For example (at this time a hypothetical one), if you got stuck with two compat packages when updates to the JDK were processed:

rpm -qa | grep “java-1.5.0-sun-compat”


remove the older package as:

yum erase java-1.5.0-sun-compat-

or, if still no go:

rpm -e java-1.5.0-sun-compat-

and try again.


Set Enviroment varibles

So… JAVA_HOME. In your shell, type:

export JAVA_HOME

or if you are C-shellish:

setenv JAVA_HOME /usr/lib/jvm/java



yum install xml-commons

download the xml-commons-apis rpm from Install by hand using

rpm -ivh xml-commons-apis rpm

For some reason yum was bugging out and not recognizing the xml-commons-apis.

(I guess this may be a case of screwy obsoletes and provides with some of the jpp packages)


Install tomcat5 and apache

yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps

We will use redhats standard apache2 with mod_jk to talk to Tomcat, so first we install:

yum install httpd mod_jk-ap20


Testing the install

Check to make sure the default tomcat users are located in /etc/tomcat5/tomcat-users.xml.

[root@centos tomcat5]# cat /etc/tomcat5/tomcat-users.xml
<?xml version=’1.0’ encoding=’utf-8’?>
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
[root@centos tomcat5]#
Test tomcat5:

/etc/rc.d/init.d/tomcat5 start

If all is well, you can see the tomcat welcome page on 8080.

Test apache:

/etc/rc.d/init.d/httpd start

If all is well, you can see the apache welcome page on 80.


configure apache to work with mod_jk

Now we will configure apache to work with mod_jk to grab everything on port 80.

make enviromet veribles persitant

edit /etc/profile

cd /etcvi profile

add lines

#Tomcat set up add by Joe 27 07 07


export JAVA_HOME




Edit tomcat configureation

Edit the file in /usr/share/tomcat5/conf/

Update the entries for workers.tomcat_home and workers.java_home



Change the worker.list from ajp12, ajp13 to just ajp13, or ajp13, inprocess if you want JNI connector. While running the JVM inside the web server gives the best performance, it lacks the stability of the out of process mode.


Comment out the worker.ajp12 entries if you want, it is not necessary.

Change from localhost to your fully qualified domain name or IP address[fully qualified domain name]

If you want to cache your connections, uncomment worker.ajp13.cachesize and add a value.


Change worker.loadbalancer.balanced_workers from ajp12, ajp13 to just ajp13.


If all you need is a simple, straight-forward out of process configuration without load balancing, you can use this as your complete file. Again remember to set the host with your fully qualified domain name or IP address


worker.ajp13.type=ajp13[fully qualified domain name]


Edit the Tomcat server.xml file located in $CATALINA_HOME/conf/

it should be /usr/share/tomcat5/conf/server.xml

Immediately below the entry <Server port=”8005″ shutdown=”SHUTDOWN”> add:

<Listener className="org.apache.jk.config.ApacheConfig" modJk="/usr/lib/httpd/modules/" workersConfig="/usr/share/tomcat5/conf/" jkLog="/var/log/tomcat5/logs/mod_jk.log" jkDebug="info" />

Find the entry <Host name=”localhost” appBase=”webapps” unpackWARs=”true” autoDeploy=”true” xmlValidation=”false” xmlNamespaceAware=”false”> and change localhost to your fully qualified domain name or IP address.

<Host name="[fully qualified domain name]" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

Immidiately following that line add:

<Listener className="org.apache.jk.config.ApacheConfig" append="true" jkWorker="ajp13" />

Restart Tomcat and verify that the dirctory auto is created and the files mod_jk.conf is created in /usr/share/tomcat5/conf/

By configuring Tomcat to create and recreate the mod_jk.conf on startup, it will automatically add a JkMount for any new webapps you deploy.


Edit apache configuration

Edit /etc/httpd/conf/httpd.conf and after the last LoadModule entry add an Include for the mod_jk.conf:

Include "/usr/share/tomcat5/conf/auto/mod_jk.conf"

Restart Apache

Browse to http://localhost/jsp-examples/ or any other webapp you have installed in Tomcat and Apache should send it to Tomcat.


Make tomcat and apache start at bootup

chkconfig –level 234 httpd on

chkconfig –level 234 tomcat5 on

Our First V.I.P.

July 11th, 2007 , 8:55

Yes folks after many months of hard work at the Hippy Factory (other wise known as the place where i work). We have are fist V.I.P thats Virtual In-house Penguin. Since the start of the year we (in an office IT team) have been trailing and experimenting with visualization using vmware’s vi3 (this product was chosen after a review and trail of many products last year).

Yesterday we finished are first move of a linux based wiki system from a physical machine to a full virtual machine. I would how ever like to point out at this time that we were unable to us any of the P2V tools on the market to accomplish this, be they provided by vmware, plate spin, ghost or various home brew scripts and linux open source tools.

While most of these tools cope ok with windows hardly any coupe with a linux base system (plate spin came closest but chocked on 64 bit process. So the advice I would give to people at the moment is if you wish to virtulize and have existing linux base system go for a re-install.

Most of the P2V products on the market at the moment can not cope with the linux for various reasons, some fail because of lvm some just failed and 64 bit killed others, and unless you have some very good knowable linux hackers around the reinstall option will be more cost effective in the short term, and a good excuse to upgrade.


If any one else would like to leave some name of tools to try i will give it a go.

As we say in BSAC plan the P2V P2V the plan 🙂

Wii Really done it now :)

July 9th, 2007 , 7:48

Yes folks over the week end we [ed: ‘we’ being Joe] bought our [ed: ‘our’ being ‘Joe’s’] Wii. First of all, I [ed: ‘I’ being ‘us’] was really surprised how small it was, but it had every thing needed to hook up to the tv and play. Plus built in wireless to hook to the Internet. It even coped with my paranoid wireless setup 🙂 .

So Sunday night was bowling and a bit of baseball. I even hit something 🙂 . Which brings me or is that Mii, you get to make your own little characters when playing, to which game to buy for it.

It also does email and lets you look at photos , plus you can buy a web browser for it. Don’t know if that’s worth it yet ?

 (edited by me!)

Good morning July

July 6th, 2007 , 7:38

we i haven’t writen much after the mud (Glastonbury festival), work has taken of like a rocket lots to do in a short time. Plus put away all the stuff we had in the field :). If i get time over the weekend i will upload the last of the pictures, quite depressing by the end mud and rubbish, is the main remberance, and a longin to be any were but there. Well on a un lighter note 🙂 the uk smoking ban is now in effect so we’re of to the pub to night.