How to install Apache Tomcat 9 in CentOS 7/8

  Apache, Dedicated Hosting

How to install Apache Tomcat 9 in CentOS 7/8

Date: 28-08-2020

Introduction:

The Apache Tomcat software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process. 

It provide a pure Java HTTP server, which will enable you to run Java files easily, which means that Tomcat is not a normal server like Apache or Nginx, because its main goal is to provide a good web environment to run Java applications only unlike other normal web servers.

Apache Tomcat Remote Code Execution Vulnerability (CVE-2019-0232) Threat  Alert - NSFOCUS, Inc., a global network and cyber security leader, protects  enterprises and carriers from advanced cyber attacks.

Step 1: Install Java (JDK)

You make sure you must have java installed on your Linux server to run Tomcat. If not, install the latest version of java by using the below command.

# yum install java-11-openjdk-devel

Once Java installed, you can verify the newly installed JAVA version running the following command.

# java -version

Sample Output:
Openjdk version "11.0.4" 2019-07-16 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)

Step 2: Install Apache Tomcat 9

Now download the latest version of Apache Tomcat 9, using following commands.

# cd /usr/local
# wget https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.tar.gz
# tar -xvf apache-tomcat-9.0.37.tar.gz
# mv apache-tomcat-9.0.37.tar.gz tomcat9

Note: Replace the version number above with the latest version available if it was different.

Before starting the Tomcat Service, configure a CATALINA_HOME environment variable in your system using the following command.

# echo "export CATALINA_HOME="/usr/local/tomcat9"" >> ~/.bashrc
# source ~/.bashrc

Now we all set to start the tomcat web server using the scripts provided by the tomcat package by using the following command.

# cd /usr/local/tomcat9/bin
# ./startup.sh 

Sample Output:

Using CATALINA_BASE:   /usr/local/tomcat9
Using CATALINA_HOME:   /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Tomcat started.

Now to open Tomcat from your browser, go to your IP or domain with the 8080 port (because Tomcat will always run on the 8080 port) as an example: mydomain.com:8080, replace mydomain.com with your IP or domain.

http://mydomain.com:8080
OR
http://domain ip address:8080

The default directory for Tomcat files will be in /usr/local/tomcat9, you can view the configuration files inside the conf folder, the main page that you have seen above, when you open your website on the 8080 port is in /usr/local/tomcat9/webapps/ROOT/.

Thank you!

LEAVE A COMMENT