Introduction
Apache Tomcat 9 is an open-source Java Servlet container developed by the Apache Software Foundation. It is widely used to deploy Java-based web applications such as JSP (JavaServer Pages) and Servlets. Tomcat is lightweight, easy to configure, and commonly used in production and development environments.
This guide explains how to install and configure Tomcat 9 on CentOS 7 and CentOS 8 systems.
Prerequisites
Before starting the installation, ensure the following:
- A server running CentOS 7 or CentOS 8
- Root or sudo user access
- Java (JDK 8 or later) installed (Tomcat requires Java to run)
- Open ports (default Tomcat port: 8080)
IMPLEMENTATION
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!
Conclusion
Installing Apache Tomcat 9 on CentOS 7/8 is a straightforward process that involves setting up Java, configuring a dedicated user, deploying Tomcat binaries, and creating a systemd service for easy management. Once installed, Tomcat provides a robust and efficient environment for hosting Java web applications. Proper security practices such as restricting access to admin panels and running Tomcat as a non-root user are essential for maintaining a secure production setup.