Wednesday, December 14, 2011

How to Install and Configure Apache Tomcat on Centos/Red Hat

The tomcat application server requires a Java application server to run on. The installation of Java, tomcat and then OpenBD follow.

1. Install Java
2. Install apache-tomcat
3. Install OpenBD
4. Configure and setup tomcat

1. Install Java

[root@egrovechn]# yum install jpackage-utils


Download Java from the Sun Website at and download the one labeled with "Java SE Development Kit (JDK)".

[root@egrovechn]# Chmod +x jdk-6u13-linux-i586-rpm.bin

You should check if Java is installed with:

[root@egrovechn]# java –version

If you get something like the below all is well:

java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

Install Tomcat

CentOS/RedHat you could install Tomcat from the YUM repositories.

[root@egrovechn]# yum install tomcat*


[root@egrovechn]# cd /opt

Download Tomcat latest verion

Extract the file

[root@egrovechn]# tar xzvf apache-tomcat-6.0.29.tar.gz

rename the folder name from apache-tomcat-6.0.29 to tomcat

[root@egrovechn]# mv apache-tomcat-6.0.29 tomcat

Start tomcat with

[root@egrovechn]# /opt/tomcat/bin/

Open http://localhost:8080. If all is fine you should see the Tomcat homepage.

Deploy (Install) OpenBD

go into the tomcat folder

[root@egrovechn]# cd /opt/tomcat/

download the openbd.war file (be sure to check the OpenBD download site for the latest war file link)

once the file has downloaded move it to the tomcat webapps folder where it will automatically deploy

[root@egrovechn]# mv /opt/tomcat/openbd.war /opt/tomcat/webapps

once the war file is in webapps Tomcat will pick it up and create an openbd folder
go to the administrator
the default bluedragon administrator password is admin

Configure Tomcat to run on startup

Now, that Tomcat and OpenDB runs nicely you might want to have it automatically started when you reboot your system. For that we can use the following script and "chkconfig" command line.

Create a "tomcat" file in "/etc/init.d"

[root@egrovechn]# vi /etc/init.d/tomcat

Copy the below startup script


# Init file for SixSigns Tomcat server
# chkconfig: 2345 55 25
# description: SixSigns Tomcat server

# Source function library.
. /etc/init.d/functions

RUN_AS_USER=tomcat # Adjust run user here

start() {
        echo "Starting Razuna Tomcat: "
        if [ "x$USER" != "x$RUN_AS_USER" ]; then
          su - $RUN_AS_USER -c "$CATALINA_HOME/bin/"
        echo "done."
stop() {
        echo "Shutting down Razuna Tomcat: "
        if [ "x$USER" != "x$RUN_AS_USER" ]; then
          su - $RUN_AS_USER -c "$CATALINA_HOME/bin/"
        echo "done."

case "$1" in
        sleep 10
        #echo "Hard killing any remaining threads.."
        #kill -9 `cat $CATALINA_HOME/work/`
        echo "Usage: $0 {start|stop|restart}"

exit 0

Save the file and exit

Add the tomcat startup script to the chkconfig with:

chkconfig --add tomcat

Then activate it for your run level. Since I am not running any X Server on my server I only want to run it on level 345. Do it with:

chkconfig --level 345 tomcat on

You can check if Tomcat will startup on reboot with listing the startup scripts with:

chkconfig –list

You should see a;

tomcat                    0:off       1:off       2:on        3:on        4:on        5:on        6:off

If you have done all well, you should now be able to bounce Tomcat with this script as well. Try it with:

/etc/init.d/tomcat restart