How to Install Tomcat7 on Centos/RHEL 6.X


Install Tomcat7 on Centos/RHEL
Make sure apache configuration is done.

Step 1. Install JAVA

# wget --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.rpm

# yum install jdk-8u5-linux-x64.rpm

# java -version

# export JAVA_HOME=/usr/java/jdk1.8.0_05

# export PATH=$PATH:$JAVA_HOME

# echo $JAVA_HOME

# vi /etc/profile.d/java.sh

#!/bin/bash
JAVA_HOME=/usr/java/jdk1.8.0_05
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.

save and exit


# chmod +x /etc/profile.d/java.sh

# source /etc/profile.d/java.sh

# java -version

Step 2: Download and Extract Tomcat Archive

# cd /tmp

# wget http://psg.mtu.edu/pub/apache/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.tar.gz

# tar -zxvf apache-tomcat-7.0.57.tar.gz

# mv apache-tomcat-7.0.57 /usr/local/tomcat7

Step 3. Add the init scripts for it.

# vi /etc/init.d/tomcat

#!/bin/bash
# description: Tomcat Start Stop Restart-SOM
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.8.0_05
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/local/tomcat7

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


# chmod 755 /etc/init.d/tomcat

Step 4 . Start the tomcat as a service.

# service tomcat start

# chkconfig tomcat on


Step 5. Access Tomcat in Browser

http://ipaddress:8080 OR http://hostname:8080

Step 6. Setup User Accounts. Paste inside <tomcat-users> </tomcat-users> tags.

# vi /usr/local/tomcat7/conf/tomcat-users.xml

<role rolename="manager-gui" />
<user username="manager" password="redhat" roles="manager-gui" />

<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="nasant" roles="manager-gui,admin-gui" />

save and exit.


# service tomcat restart

# service httpd restart

----- DONE,Thanks -----