INSTALL JAVA 8
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.rpm" -O /opt/jdk-8-linux-x64.rpm
rpm -Uvh /opt/jdk-8-linux-x64.rpm
CONFIGURE JAVA
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_101/jre/bin/java 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_101/bin/jar 20000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_101/bin/javac 20000
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_101/jre/bin/javaws 20000
alternatives --set java /usr/java/jdk1.8.0_101/jre/bin/java
alternatives --set javaws /usr/java/jdk1.8.0_101/jre/bin/javaws
alternatives --set javac /usr/java/jdk1.8.0_101/bin/javac
alternatives --set jar /usr/java/jdk1.8.0_101/bin/jar
check the JAVA version
java -version
INSTALL TOMCAT 8
useradd -r tomcat8 --shell /bin/false
wget http://www.us.apache.org/dist/tomcat/tomcat-8/v8.5.5/bin/apache-tomcat-8.5.5.tar.gz
tar -zxf /tmp/apache-tomcat-8.5.5.tar.gz -C /opt
ln -s /opt/apache-tomcat-8.5.5 /opt/tomcat-latest
chown -hR tomcat8: /opt/tomcat-latest /opt/apache-tomcat-8.5.5
CREATE TOMCAT 8 SERVICE
vi /etc/init.d/tomcat8
paste
#!/bin/bash
#
# tomcat8
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat8
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start:
# Default-Stop:
# Description: Tomcat 8
# Short-Description: start and stop tomcat
### END INIT INFO
## Source function library.
#. /etc/rc.d/init.d/functions
export JAVA_HOME=/usr/java/default
export JAVA_OPTS="-Dfile.encoding=UTF-8 \
-Dnet.sf.ehcache.skipUpdateCheck=true \
-XX:+UseConcMarkSweepGC \
-XX:+CMSClassUnloadingEnabled \
-XX:+UseParNewGC \
-XX:MaxPermSize=128m \
-Xms512m -Xmx512m"
export PATH=$JAVA_HOME/bin:$PATH
TOMCAT_HOME=/opt/tomcat-latest
TOMCAT_USER=tomcat8
SHUTDOWN_WAIT=20
tomcat_pid() {
echo `ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'`
}
start() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is already running (pid: $pid)"
else
# Start tomcat
echo "Starting tomcat"
ulimit -n 100000
umask 007
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/startup.sh
fi
return 0
}
stop() {
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Stoping Tomcat"
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/shutdown.sh
let kwait=$SHUTDOWN_WAIT
count=0;
until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
do
echo -n -e "\nwaiting for processes to exit";
sleep 1
let count=$count+1;
done
if [ $count -gt $kwait ]; then
echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds"
kill -9 $pid
fi
else
echo "Tomcat is not running"
fi
return 0
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
pid=$(tomcat_pid)
if [ -n "$pid" ]
then
echo "Tomcat is running with pid: $pid"
else
echo "Tomcat is not running"
fi
;;
esac
exit 0
chmod +x /etc/init.d/tomcat8
service tomcat8 start
chkconfig tomcat8 on
Setup User Accounts and Access
Edit conf/tomcat-users.xml
<!-- user manager can access only manager section -->
<role rolename="manager-gui" />
<user username="techoism" password="_SECRET_PASSWORD_" roles="manager-gui" />
<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />
Edit /webapps/manager/META-INF/context.xml
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
</Context>