CentOS: Java & Tomcat Installation

Install Java 1.6.0_20:
The following instructions assume that there is no root access to the system. Thus, Java must be made available in a home directory of user named webadmin.
Download the file:
cd ~
wget http://software.cs.utep.edu/LINUX/Java/jdk-6u20-linux-x64.bin
Set execution permissions:
chmod +x jdk-6u20-linux-x64.bin
Install:
# sh jdk-6u20-linux-x64.bin
./jdk-6u20-linux-x64.bin
Install Tomcat:
cd ~
wget https://archive.apache.org/dist/tomcat/tomcat-5/v5.5.35/bin/apache-tomcat-5.5.35.tar.gz
tar -xzvf apache-tomcat-5.5.35.tar.gz
mv apache-tomcat-5.5.35 ~/webserver
rm apache-tomcat-5.5.35.tar.gz
Set environment:
vim ~/webserver/bin/setenv.sh
— paste these lines —
JAVA_HOME=/home/webadmin/jdk1.6.0_20/
JRE_HOME=/home/webadmin/jdk1.6.0_20/jre
—- alternative —-
Create a symlink for Tomcat pointing toward Java directory:
ln -s /home/webadmin/jdk1.6.0_20 /home/webadmin/pkg/share/jre180131
OR Add Java into the Bash Profile
vim ~/.bash_profile
PATH=$PATH:$HOME/jdk1.6.0_20
export JAVA_HOME=/home/webadmin/jdk1.6.0_20
export PATH
=== didn’t work ===
vim ~/webserver/bin/startup.sh
# JAVA_HOME for Tomcat
JAVA_HOME = /home/webadmin/jdk1.6.0_20
JRE_HOME = /home/webadmin/jdk1.6.0_20/jre
export JAVA_HOME
export JRE_HOME
vim ~/webserver/bin/shutdown.sh
# JAVA_HOME for Tomcat
JAVA_HOME = /home/webadmin/jdk1.6.0_20
JRE_HOME = /home/webadmin/jdk1.6.0_20/jre
export JAVA_HOME
export JRE_HOME
=== didn’t work ===
Start Tomcat:
~/webserver/bin/startup.sh
Check running status:
wget http://127.0.0.1:8080
tail ~/webserver/logs/catalina.out
Set Tomcat administration access:
vim ~/webserver/conf/tomcat-users.xml
Edit Crontab for autorun:
crontab -e
Add this line:
@reboot /home/webadmin/webserver/bin/startup.sh
Script to send an email if Tomcat Is Not running:
kill -0 `cat $CATALINA_PID` > /dev/null 2>&1
if [ $? -gt 0 ]
then
echo “Check tomcat” | mailx -s “Tomcat not running” support@kimconnect.com
fi

The following requires root privileges:
Create a Tomcat control script at startup directory:
vim /etc/init.d/tomcat
#! / bin / bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start / shutdown script
# processname: tomcat
JAVA_HOME = /home/webadmin/jdk1.6.0_20
export JAVA_HOME
TOMCAT_HOME = /home/webadmin/webserver/bin/
START_TOMCAT = /home/webadmin/webserver/bin/startup.sh
STOP_TOMCAT = /home/webadmin/webserver/bin/shutdown.sh
start () {
        echo -n “Starting tomcat:”
        cd $ TOMCAT_HOME
        $ {START_TOMCAT}
        echo “done.”
}
stop () {
        echo -n “Shutting down tomcat:”
        cd $ TOMCAT_HOME
        $ {STOP_TOMCAT}
– 4 out of 5 –
        echo “done.”
}
case “$ 1” in
start)
        start
        ;;
stop)
        stop
        ;;
        start
        ;;
*)
        echo “Usage: $ 0 {start | stop | restart}”
esac
exit 0
Configure system to automatically start Tomcat:
chkconfig –add tomcat
chkconfig -level 234 tomcat on

Leave a Reply

Your email address will not be published. Required fields are marked *