Home  »  ArticlesGuidesHow ToTechnology   »   How to Install Apache Tomcat 10 on CentOS 8/7 or Rocky Linux 8

How to Install Apache Tomcat 10 on CentOS 8/7 or Rocky Linux 8

Apache Tomcat is a widely-used open-source application server that is essential for running Java-based web applications. If you’re using CentOS 8, CentOS 7, or Rocky Linux 8 and need to set up the latest version of Apache Tomcat, this guide is here to help. In this tutorial, we’ll walk you through the step-by-step process of installing Apache Tomcat 10 on your CentOS or Rocky Linux system.

Prerequisites:

Before we start with the installation, make sure you have the following prerequisites:

  1. A CentOS 8, CentOS 7, or Rocky Linux 8 server.
  2. Administrative (sudo) privileges.
  3. Java Development Kit (JDK) installed. You can install it using the following command:
$ sudo yum install java

Step 1: Update Your System

Always begin by ensuring that your system is up to date with the latest packages. Open a terminal and run:

$ sudo yum update

Step 2: Download Apache Tomcat 10

Visit the official Apache Tomcat download page to find the latest version of Tomcat 10. Copy the download link for the tar.gz file for your preferred version.

cd /tmp
wget https://downloads.apache.org/tomcat/tomcat-10/v10.x.y/z/apache-tomcat-10.x.y.tar.gz

Replace 10.x.y with the specific version number you want to install.

Step 3: Extract Tomcat

Once the download is complete, extract the downloaded Apache Tomcat archive:

$ tar -xzvf apache-tomcat-10.x.y.tar.gz

Step 4: Move Tomcat to /opt Directory

It’s a good practice to move Apache Tomcat to the /opt directory for better organization and system-wide accessibility:

$ sudo mv apache-tomcat-10.x.y /opt/tomcat

Step 5: Configure Environment Variables

To ensure that Apache Tomcat runs smoothly, you need to set up environment variables. Create a new file for Tomcat environment variables:

$ sudo nano /etc/profile.d/tomcat.sh

Add the following content to the file, replacing 10.x.y with your Tomcat version:

$ export CATALINA_HOME="/opt/tomcat"
$ export PATH="$CATALINA_HOME/bin:$PATH"

Save the file and exit the text editor.

Step 6: Apply the Environment Variables

Apply the environment variables by running:

$ source /etc/profile.d/tomcat.sh

Step 7: Start and Enable Tomcat Service

You can now start Apache Tomcat:

$ sudo systemctl start tomcat

To ensure Tomcat starts automatically at boot, enable it:

$ sudo systemctl enable tomcat

Step 8: Adjust Firewall Rules

If you have a firewall enabled on your server, open the HTTP and HTTPS ports to allow external access to Apache Tomcat:

$ sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
$ sudo firewall-cmd --permanent --zone=public --add-port=8443/tcp
$ sudo firewall-cmd --reload

Step 9: Access the Tomcat Manager

You can access the Apache Tomcat Manager using a web browser by navigating to:

http://your_server_ip:8080

Replace your_server_ip with your server’s IP address. You’ll be prompted to enter the Tomcat manager credentials, which are defined in the tomcat-users.xml file located in the Tomcat conf directory.

Conclusion:

You’ve successfully installed the latest Apache Tomcat 10 on your CentOS 8, CentOS 7, or Rocky Linux 8 server. You can now deploy your Java web applications and enjoy the benefits of this robust application server. If you encounter any issues or need further assistance, refer to the official Apache Tomcat documentation or seek help from the Tomcat community.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, How To, Technology