Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Friday, 25 March 2016

How to Install Tomcat 9 With Java 9 On CentOS/RHEL 6x


How to Install Tomcat 9 With Java 9 On CentOS/RHEL 6x

 
 Q. What is Apache Tomcat ?

Ans: Tomcat is an open source application server from the Apache Software Foundation that executes Java servlets and renders Web pages that include Java Server Page coding.

Step: 1. Bind the Hosts File :

# vi /etc/hosts

192.168.72.220    ser1.kmi.com    ser1

-- Save & Quit (:wq)

Step: 2. Stop the IPTables & Selinux :

# service iptables stop
# chkconfig iptables off

# vi /etc/sysconfig/selinux

SELINUX=disabled

-- Save & Quit (:wq)

Step: 3. Update the Date Time on the Server :

# yum -y install ntp
# service ntpd restart
# ntpdate pool.ntp.org
# chkconfig ntpd on

Step: 4. Reboot the System :

# init 6

Step: 5. Download & Install Java 9 :

# cd /opt
# wget http://download.java.net/java/jdk9/archive/104/binaries/jdk-9-ea+104_linux-x64_bin.tar.gz
# tar -zxvf jdk-9-ea+104_linux-x64_bin.tar.gz
# cd jdk-9/
# alternatives --install /usr/bin/java java /opt/jdk-9/bin/java 2
# alternatives --config java

There may Be more that 1 programs which provide 'java'. Select the version Which is downloaded.

Selection    Command
-----------------------------------------------
*  1           /opt/jdk1.7.0_71/bin/java
 + 2           /opt/jdk1.8.0_45/bin/java
   3           /opt/jdk1.8.0_66/bin/java
   4           /opt/jdk-9/bin/java
  
Enter to keep the current selection[+], or type selection number: 4

# alternatives --install /usr/bin/jar jar /opt/jdk-9/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk-9/bin/javac 2
# alternatives --set jar /opt/jdk-9/bin/jar
# alternatives --set javac /opt/jdk-9/bin/javac

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

#!/bin/bash
JAVA_HOME=/opt/jdk-9/
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.

-- Save & Quit (:wq)
 
# chmod +x /etc/profile.d/java.sh
# source /etc/profile.d/java.sh

Step: 6. Check the Installed Java Version :

# java -version

java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+104-2016-02-03-214959.javare.4385.nc)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+104-2016-02-03-214959.javare.4385.nc, mixed mode)

Step: 7. Download & Install Tomcat 9 :

# cd /opt
# wget http://www.us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M3/bin/apache-tomcat-9.0.0.M3.tar.gz
# tar -zxvf apache-tomcat-9.0.0.M3.tar.gz
# mv apache-tomcat-9.0.0.M3 /usr/local/tomcat9

Step: 8. Create a init Script for run the Tomcat as a Service :

# vi /etc/init.d/tomcat

#!/bin/bash
# description: Tomcat Start Stop Restart-SOM
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/opt/jdk-9
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/local/tomcat9

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 & Quit (:wq)

# chmod 755 /etc/init.d/tomcat

Step: 9. Manage Tomcat Manager & Admin Panel :

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

### Add these lines in between "<tomcat-users>" Tag. Change the Password & User Name.

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

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

-- Save & Quit (:wq)

Step: 10. Start the Tomcat Service :

# service tomcat restart
# chkconfig tomcat on

Step: 11. Check on Web Browser :

http://<IP_Address>:8080

Click on Manager App & Login with Manager Creds
Click on Host Manager & Login with Admin Creds

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog

1 comment:

  1. Thanks for sharing, i have query regarding how to uninstall.

    ReplyDelete

Copyright © 2016 Kousik Chatterjee's Blog