Search This Blog

Sunday, June 20, 2010

Tomcat Installation

Step 1 : Install an Operating System.

Operating System: OEL5.2_32bit
For Default installation you will need first 3 cds namely.

Enterprise-R5-U2-Server-i386-disc1.iso
Enterprise-R5-U2-Server-i386-disc2.iso
Enterprise-R5-U2-Server-i386-disc3.iso

Step2:Install Tomcat, JDK, JRE and define a save point.

We are going to install following softwares in the newly created machines.

Make a folder named install in /.
Copy all the required softwares in /install.
apache-tomcat-5.5.29.tar.gz
jdk-6u20-linux-i586-rpm.bin
jre-6u20-linux-i586-rpm.bin

Installation Guide:

1)apache-tomcat-5.5.29.tar.gz:
I have choosen linux version of tomcat.
For Initial Setup You should always go for
Core version download.
downloaded apache-tomcat-5.5.29.tar.gz
#gunzip apache-tomcat-5.5.29.tar.gz
#tar -xvf apache-tomcat-5.5.29.tar.gz
This will create a new folder as apache-tomcat-5.5.29 in same directory.
go to apache-tomcat-5.5.29/bin
run
#./startup.sh

it will not run as java new version is not yet installed.

2) jdk-6u20-linux-i586-rpm.bin:
Next we will install latest jdk version.
#chmod +x jdk-6u20-linux-i586-rpm.bin
#./ jdk-6u20-linux-i586-rpm.bin
This will create a new folder in
/usr/java/jdk1.6.0_20/
use it for JAVA_HOME.



3) jre-6u20-linux-i586-rpm.bin
Next we will install latest jre version.
#chmod +x jre-6u20-linux-i586-rpm.bin
#./jre-6u20-linux-i586-rpm.bin
This will create a new folder in
/usr/java/jre1.6.0_20/
use it for JRE_HOME.

After installation of above mentioned 3 important software its time to take snapshot of the machine.


Step3:Configure java and TOMCAT and define a savepoint.

# javac -version
javac 1.6.0_20
# java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

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 PARTICULAR PURPOSE.


######At this time java is set to default java in linux our aim is to change it to latest java version.
for setting up this you need root login therefore type

#su

######Then you type

#/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_20/bin/java 2

######Finally you type
#;/usr/sbin/alternatives --config java
........ and choose '2'nd option.


Now make sure you disable firewall .

# system-config-securitylevel
Disable the firewall

I have created a script called Tomcat and pasted following content inside it.
# This is the init script for starting up the
# Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

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

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

tomcat=/install/apache-tomcat-5.5.29
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jdk1.6.0_20


start(){
echo -n $"Starting Tomcat service: "
#daemon -c
$startup
RETVAL=$?
echo
}

stop(){
action $"Stopping Tomcat service: " $shutdown
RETVAL=$?
echo
}

restart(){
stop
start
}


# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
# This doesn't work ;)
status tomcat
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac

exit 0


Edit the lines that start with tomcat and export to match where you installed tomcat and your jdk.

Note: I can't remember where I first got the original version of this script so if you deserve credit for this,

Save the script with name “tomcat” to a location “/etc/init.d”

(at least on most newer releases since /etc/init.d is a standard now). Then you have to allow execute access to the script, so run:

#chmod a+x tomcat
Add to appropriate run level directories

The easy way to do this is to just simply run:

#chkconfig --add tomcat


Add username/Password for tomcat manager:
How to add a new user name to tomcat manager:

just add line number 3 and 6 to /install/apache-tomcat-5.5.29/conf/tomcat-users.xml
xml version='1.0' encoding='utf-8'?>
tomcat-users>
role rolename="manager"/>
role rolename="tomcat"/>
role rolename="role1"/>
user username="manager" password="tomcat" roles="manager,tomcat"/>
user username="tomcat" password="tomcat" roles="tomcat"/>
user username="both" password="tomcat" roles="tomcat,role1"/>
user username="role1" password="tomcat" roles="role1"/>
tomcat-users>

Restart tomcat server.
By using service tomcat restart.



To check whether the Tomcat is running or not.

#netstat -ntpl | grep java
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 6375/java
tcp 0 0 :::8009 :::* LISTEN 6375/java
tcp 0 0 :::8080 :::* LISTEN 6375/java

You should see at least one java process and you can use ps to identify if this is Tomcat.

# ps -ef | grep 6375
root 6375 1 0 May18 pts/2 00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root 9222 5091 0 18:29 pts/2 00:00:00 grep 6375

No comments:

Post a Comment