Tomcat is used for developing web applications, we will install Tomcat 7 and the JDK 8 in CentOS
we'll need to install the JDK and Tomcat can support minimum JDK version 1.6
Install JDK 8 :
We can download JDK with latest version from the below url :
http://www.oracle.com/technetwork/java/javase/downloads
Extract that archive file
# tar –xf jdk-8u5-linux-x64.tar.gz
After extracted the file name should be jdk-8u5 copy or move this file to Java directory
Create a new directory /usr/java.
# mkdir /usr/java
# mv jdk-8u5 /usr/java/.
# mv jdk-8u5 /usr/java/.
Set JAVA_Home path:
Set the JAVA_HOME path. This is where we installed our JDK above.
To set it for your current session, you can issue the following from the CLI
JAVA_HOME=/usr/java/jdk-8u5
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
Once you have added the above to ~/.bash_profile or ~/.bashrc, check that the JAVA_HOME is set correctly.
echo $JAVA_HOME
/usr/java/jdk-8u5
Download and extract tomcat 7
We have decided tomcat path switch to /usr/local
cd /usr/local
wget http://www.poolsaboveground.com/apache/tomcat/tomcat-7/v7.0.54/bin/apache-tomcat-7.0.54.tar.gz
Once extracted the file name should be apache-tomcat-7.0.54
# tar -zxvf apache-tomcat-7.0.54.tar.gz
Configure Tomcat for start/stop :
# touch /etc/init.d/tomcat7
The below scripts for make easy way to start, stop and restart tomcat in single command,
# vi /etc/init.d/tomcat7
#!/bin/bash
# this script for Tomcat Start Stop Restart
JAVA_HOME=/usr/java/jdk-8u5
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/local/apache-tomcat-7.0.54
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
Now, $CATALINA_HOME directory set to /usr/local/apache-tomcat-7.0.54
Give executable permission to that file, using the chmod command
# chmod +x /etc/init.d/tomcat7
or
# chmod 755 /etc/init.d/tomcat7
Use the chkconfig utility to start Tomcat service during the system boot time,
# chkconfig --add tomcat7
# chkconfig --level 234 tomcat on
# chkconfig --level 234 tomcat on
Once you have update verify it,
chkconfig --list tomcat
tomcat7 0:off 1:off 2:on 3:on 4:on 5:off 6:off
To start tomcat server:
/etc/init.d/tomcat7 start
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.54
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.54 Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.54/temp
Using JRE_HOME: /usr/java/jdk-8u5
Using CLASSPATH: /usr/local/apache-tomcat-7.0.54/bin/bootstrap.jar:/ /usr/local/apache-tomcat-7.0.54/bin/tomcat-juli.jar
To stop tomcat server:
/etc/init.d/tomcat7 start
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.54
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.54 Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.54/temp
Using JRE_HOME: /usr/java/jdk-8u5
Using CLASSPATH: /usr/local/apache-tomcat-7.0.54/bin/bootstrap.jar:/ /usr/local/apache-tomcat-7.0.54/bin/tomcat-juli.jar
We should check tomcat log file the name of catalina.out its located under /usr/local/apache-tomcat-7.0.54/logs/ catalina.out
Now, We can access tomcat Manage on your browser:
http://192.168.0.1:8080/ or your domain name http://domainame:8080/
Create Tomcat User:
# cd under /usr/local/apache-tomcat-7.0.54/conf/
# vi tomcat-user.xml
# vi tomcat-user.xml
we should add in tomcat-user.xml
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin"/>
<user username="admin" password="j7#$#@#54t4$" roles="admin,manager,manager-gui"/>
</tomcat-users>
Comments (0)