• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Saturday, June 14, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Install Apache Tomcat on Rocky Linux

in Linux OS, Red Hat Enterprise Linux, Rocky Linux
How to Install Tomcat on Rocky Linux

In this tutorial, we’ll guide you through the process of how to install Apache Tomcat on Rocky Linux. Tomcat is a popular open-source Java Servlet container, developed by the Apache Software Foundation. It’s widely used for deploying and running Java-based web applications.

Prerequisites

Before we begin, make sure you have:

  • A Rocky Linux system up and running.
  • A user with sudo privileges.

How to Install Apache Tomcat on Rocky Linux

Update Your System

First, update your system packages to their latest versions:

sudo dnf update -y

Install Java Development Kit (JDK)

Tomcat requires Java Development Kit (JDK) to run. Install OpenJDK 11 using the following command:

sudo dnf install java-11-openjdk-devel -y

Verify the Java installation by checking its version:

java -version
Verify the Java installation by checking its version

Create Tomcat User and Group on Rocky Linux

Create a new user and group for running the Tomcat service. This ensures better security and isolation:

sudo groupadd tomcat
sudo useradd -M -s /sbin/nologin -g tomcat -d /opt/tomcat tomcat

Download and Install Apache Tomcat on Rocky Linux

Download the latest version of Tomcat from the official website. At the time of writing, the latest version is 9.0.x. Adjust the version number accordingly:

wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.x/bin/apache-tomcat-9.0.x.tar.gz
Example: wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74.tar.gz
Download Apache Tomcat on Rocky Linux

Extract the downloaded archive and move it to the /opt/tomcat directory:

sudo tar xf apache-tomcat-9.0.x.tar.gz
sudo mv apache-tomcat-9.0.x /opt/tomcat

Change the ownership of the Tomcat directory to the tomcat user and group:

sudo chown -R tomcat:tomcat /opt/tomcat

Configure Systemd Service on Rocky Linux

Create a new systemd service file for Tomcat:

sudo nano /etc/systemd/system/tomcat.service

Add the following content to the file:

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_BASE=/opt/tomcat"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save the file and exit the editor.

Start and Enable Tomcat on Rocky Linux

Reload the systemd daemon to register the new service:

sudo systemctl daemon-reload

Start the Tomcat service:

sudo systemctl start tomcat

Enable the Tomcat service to start on boot:

sudo systemctl enable tomcat

Check the status of the Tomcat service:

sudo systemctl status tomcat

Configure Firewall on Rocky Linux

If you have a firewall running, allow the default Tomcat port (8080) through the firewall:

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

Access Tomcat Web Interface

Now that Tomcat is installed and running, you can access the web interface to manage your Tomcat server. Open your web browser and navigate to the following URL:

http://your_server_ip:8080

Replace your_server_ip with the actual IP address of your Rocky Linux server. You should see the Apache Tomcat welcome page.

Secure the Tomcat Manager and Host Manager Applications (Optional)

By default, the Tomcat Manager and Host Manager applications are not secured. To secure them, you need to create a user with a role that has access to these applications.

Open the tomcat-users.xml file:

sudo nano /opt/tomcat/conf/tomcat-users.xml

Add the following lines inside the <tomcat-users> element:

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

Replace your_username and your_password with your desired username and password.

Save the file and exit the editor. Restart Tomcat for the changes to take effect:

sudo systemctl restart tomcat

Now, you can access the Tomcat Manager and Host Manager applications by clicking on their respective links on the Tomcat welcome page and entering your username and password when prompted.

Conclusion

You have successfully installed and configured Apache Tomcat on your Rocky Linux server. You can now deploy and manage Java-based web applications using the Tomcat Manager and Host Manager applications. Remember to keep your Tomcat installation up-to-date with the latest security patches and updates. Learn How to Set up NTP Server on Rocky Linux and How to Install Bacula Backup Server on Rocky Linux

ShareTweet
Previous Post

How to Set up NTP Server on Rocky Linux

Next Post

How to Install Django on Rocky Linux

Related Posts

How to Install and Configure OpenVAS on Rocky Linux

How to Install and Configure OpenVAS on Rocky Linux

How to Install and Configure Nikto on Rocky Linux

How to Install and Configure Nikto on Rocky Linux

Set up FreeIPA on Rocky Linux

How to Install and Configure FreeIPA on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.