About Me

My photo
Kalyan Kumar Pasupuleti B-Tech(Information Technology). • AWS Certified Solutions Architect - Associate • RedHat Certified Engineer(RHCE) • Directory Services and Authentication Certificate of Expertise(LDAP) • Red Hat SELinux Policy Administration Certificate of Expertise(SELinux) • Network Services Security Certificate of Expertise (Network Services) • RedHat Certified Virtualization Administrator(RHCVA) • Red Hat Certified Security Specialist (RHCSS) Working as Cloud DevOps engineer

Wednesday, April 24, 2013

How to install JDK-1.6 and Tomcat 7 on RHEL/CentOS?

This is a small article describes how to install JDK-1.6 and Tomcat 7 on a Linux box.

Prerequisites

1. jdk-6u39-linux-i586.bin
2. apache-tomcat-7.0.39.tar.gz

Download the files using below URLs

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
http://tomcat.apache.org/download-70.cgi#7.0.39

According to my configuration I have downloaded both the files to /opt folder.

After downloading install JDK as shown below:


[root@cluster1 ~]# cd /opt/
[root@cluster1 opt]# ls -l

-rw-r--r-- 1 root root 71756435 Apr 24 06:18 jdk-6u39-linux-i586.bin

Provide the execute permission to the bin file

[root@cluster1 opt]# chmod +x jdk-6u39-linux-i586.bin




[root@cluster1 opt]# ls -l jdk-6u39-linux-i586.bin
-rwxr-xr-x 1 root root 71756435 Apr 24 06:18 jdk-6u39-linux-i586.bin

Now execute the below command to install JDK:

[root@cluster1 opt]# ./jdk-6u39-linux-i586.bin

[root@cluster1 opt]# ./jdk-6u39-linux-i586.bin
Unpacking...
        .
        .
        .

Press Enter to continue..... (Press enter key here to complete the unpacking)

Now You observe there is a folder created in /opt folder with the name jdk1.6.0_39

[root@cluster1 opt]# ll
drwxr-xr-x 8 root root     4096 Apr 24 06:23 jdk1.6.0_39
-rwxr-xr-x 1 root root 71756435 Apr 24 06:18 jdk-6u39-linux-i586.bin

Now download and install tomcat using below URL:


[root@cluster1 opt]# wget http://apache.techartifact.com/mirror/tomcat/tomcat-7/v7.0.39/bin/apache-tomcat-7.0.39.tar.gz

Now extract the tar ball using below command:

[root@cluster1 opt]# tar -zxvf apache-tomcat-7.0.39.tar.gz

Now check the folder apache-tomcat-7.0.39 in /opt directory.

[root@cluster1 opt]# ls -l
total 77824
drwxr-xr-x 9 root root     4096 Apr 24 06:25 apache-tomcat-7.0.39
-rw-r--r-- 1 root root  7831716 Apr 24 06:24 apache-tomcat-7.0.39.tar.gz

The tomcat startup and shutdown scripts are located in below paths:

Startup script path: /opt/apache-tomcat-7.0.39/bin/startup.sh
Shutdown script path: /opt/apache-tomcat-7.0.39/bin/shutdown.sh

Now one more step ahead to complete this configuration.
You need to setup Tomcat to run as a service. So create a service (file) as shown below:

[root@cluster1 opt]# vim /etc/init.d/tomcat7

#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/opt/jdk1.6.0_39/   # This is your java home path
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/opt/apache-tomcat-7.0.39 # This is your tomcat home directory

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


Save and exit.

Now provide the execute permission to this service.

[root@cluster1 opt]# chmod +x /etc/init.d/tomcat7

Now Make this service to be run after restarting the Linux box as well by doing chkconfig:

[root@cluster1 opt]# chkconfig tomcat7 on
[root@cluster1 opt]# chkconfig --list tomcat7
tomcat7         0:off   1:off   2:on    3:on    4:on    5:on    6:off

Now all is set and it is the time to start your tomcat service and verify the site.

[root@cluster1 opt]# /etc/init.d/tomcat7 start
Using CATALINA_BASE:   /opt/apache-tomcat-7.0.39
Using CATALINA_HOME:   /opt/apache-tomcat-7.0.39
Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.39/temp
Using JRE_HOME:        /opt/jdk1.6.0_39/
Using CLASSPATH:       /opt/apache-tomcat-7.0.39/bin/bootstrap.jar:/opt/apache-tomcat-7.0.39/bin/tomcat-juli.jar

Verify the service is running or not:

[root@cluster1 opt]# ps -ef | grep java
root      8873     1  8 07:05 pts/3    00:00:02 /opt/jdk1.6.0_39//bin/java -Djava.util.logging.config.file=/opt/apache-tomcat-7.0.39/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/apache-tomcat-7.0.39/endorsed -classpath /opt/apache-tomcat-7.0.39/bin/bootstrap.jar:/opt/apache-tomcat-7.0.39/bin/tomcat-juli.jar -Dcatalina.base=/opt/apache-tomcat-7.0.39 -Dcatalina.home=/opt/apache-tomcat-7.0.39 -Djava.io.tmpdir=/opt/apache-tomcat-7.0.39/temp org.apache.catalina.startup.Bootstrap start


We can now access the Tomcat Manager page at:

http://yourdomain.com:8080 or http://yourIPaddress:8080 and we should see the Tomcat home page.


All the best.

No comments:

Post a Comment