Install, config Tomcat 7 and Java (JDK) on CentOS, RHEL (in 4 steps scenario)

Review Overview

Total

0%

Scenario

Step 1: Download the latest JDK here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

We’ll install the latest JDK, which is JDK 7, Update 5. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I’ll need: jdk-7u5-linux-x64.tar.gz.

If you are on 32 bit, you’ll need: jdk-7u5-linux-i586.tar.gz

Start by creating a new directory 


mkdir /usr/java:

cd /usr/java/jdk

# configure jdk

JAVA_HOME=/usr/java/jdk

export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH

export PATH

Step 2: Download and Unpack Tomcat

http://tomcat.apache.org/download-70.cgi

Path: /usr/share

cd /usr/share 

Step 3: Configure Tomcat as a Service 

We will now see how to run Tomcat as a service and create a simple Start/Stop/Restart script, as well as to start Tomcat at boot.

Change to the /etc/init.d directory and create a script called ‘tomcat’ as shown below

cd /etc/init.d ch

vi tomcat


##################################################

#!/bin/bash

# description: Tomcat Start Stop Restart

# processname: tomcat

# chkconfig: 234 20 80

JAVA_HOME=/usr/java/jdk

export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH

export PATH

CATALINA_HOME=/usr/share/apache-tomcat-7.0.59

case $1 in

start)

sh $CATALINA_HOME/bin/startup.sh

;;

stop)

sh $CATALINA_HOME/bin/shutdown.sh

;;

restart)

sh $CATALINA_HOME/bin/shutdown.sh

sh $CATALINA_HOME/bin/startup.sh

;;

esac

exit 0

##################################################

Startup & Shutdown scripts path: /usr/share/apache-tomcat-7.0.29/bin

CATALINA_HOME is the Tomcat home directory (/usr/share/apache-tomcat-7.0.59)

chmod 755 tomcat

chkconfig –add tomcat

chkconfig –level 234 tomcat on

Step 4: Configure Tomcat

To set roles, user name(s) and password(s), we need to configure the tomcat-users.xml file located at $CATALINA_HOME/conf/tomcat-users.xml.

Shares

About ddnbgroup

You Might Also Like