• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

  • 00:41 hostnamectl set-hostname tomcat.example.com
  • 01:41 dnf -y install java-11-openjdk java-11-openjdk-devel
  • 02:02 groupadd tomcat
  • 02:31 useradd -s /bin/nologin -g tomcat -d /opt/tomcat/ tomcat
  • 03:03 wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.23/bin/apache-tomcat-10.0.23.tar.gz
  • 03:22 tar xvf apache-tomcat-10.0.23.tar.gz -C /opt/tomcat/ --strip-
  • 03:50 chown -R tomcat:tomcat /opt/tomcat/
  • 04:12 sh -c 'chmod +x /opt/tomcat/bin/*.sh'
  • 04:49 vim /etc/systemd/system/tomcat.service
  • 05:20 systemctl daemon-reload
  • 05:55 firewall-cmd --permanent --list-all
  • 06:05 vim /opt/tomcat/conf/tomcat-users.xml
  • 08:37 firewall-cmd --add-port=8080/tcp --permanent
  • 17:19 vim /opt/tomcat/webapps/manager/META-INF/context.xml
7165

To Install And Configure Apache Tomcat 10 In Rocky Linux 8.6

Introduction

Apache Tomcat is a popular open-source web server and Servlet container for Java code. As the reference implementation of Java Servlet and Java Server Pages (JSP), Tomcat was originally developed at Sun Microsystems, which afterward donated the code base to the Apache Software Foundation.

Installation procedure:

Step 1: Check the installed version of OS by using the below command

[root@linuxhelp ~]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"

Step 2: Set the host name by using the below command

[root@linuxhelp ~]# hostnamectl set-hostname tomcat.example.com

Step 3: Run the bash command to update host name in shell by using the below command

[root@linuxhelp ~]# bash

Step 4: Put the host entry by using the below command

[root@tomcat ~]# vim /etc/hosts
192.168.6.122 tomcat.example.com
Syntax = <serverip> <hostname> 

Step 5: Install OpenJDK by using the below command

[root@tomcat ~]# dnf -y install java-11-openjdk java-11-openjdk-devel
Rocky Linux 8 - AppStream                                     3.4 MB/s | 9.6 MB     00:02    
Rocky Linux 8 - BaseOS                                        3.4 MB/s | 6.7 MB     00:01    
Rocky Linux 8 - Extras                                         12 kB/s |  11 kB     00:00    
Dependencies resolved.
==============================================================================================
 Package                    Arch     Version                                Repository   Size
==============================================================================================
Installing:
 java-11-openjdk            x86_64   1:11.0.16.0.8-1.el8_6                  appstream   271 k
 java-11-openjdk-devel      x86_64   1:11.0.16.0.8-1.el8_6                  appstream   3.4 M
Installing dependencies:
 copy-jdk-configs           noarch   4.0-2.el8                              appstream    29 k
 java-11-openjdk-headless   x86_64   1:11.0.16.0.8-1.el8_6                  appstream    40 M
 javapackages-filesystem    noarch   5.3.0-2.module+el8.3.0+125+5da1ae29    appstream    29 k
 lksctp-tools               x86_64   1.0.18-3.el8                           baseos       98 k
 ttmkfdir                   x86_64   3.0.9-54.el8                           appstream    61 k
 tzdata-java                noarch   2022c-1.el8                            appstream   185 k
 xorg-x11-fonts-Type1       noarch   7.5-19.el8                             appstream   521 k
Enabling module streams:

 javapackages-runtime                201801                                                  
Transaction Summary

Step 6: Add Tomcat group by using the below command

[root@tomcat ~]# groupadd tomcat

Step 7: Create Tomcat directory under /opt by using the below command

[root@tomcat ~]# mkdir /opt/tomcat

Step 8: Create Tomcat user and the disable login by using the below command

[root@tomcat ~]# useradd -s /bin/nologin -g tomcat -d /opt/tomcat/ tomcat

Step 9: Download Tomcat package, here I’m downloading version 10

[root@tomcat ~]# wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.23/bin/apache-tomcat-10.0.23.tar.gz
--2022-09-01 16:38:43--  https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.23/bin/apache-tomcat-10.0.23.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11972768 (11M) [application/x-gzip]
Saving to: ‘apache-tomcat-10.0.23.tar.gz’

apache-tomcat-10.0.23.t 100%[=============================>]  11.42M  6.73MB/s    in 1.7s    
2022-09-01 16:38:44 (6.73 MB/s) - ‘apache-tomcat-10.0.23.tar.gz’ saved [11972768/11972768]

Step 10: Extract the files in the tomcat directory by using the below command

[root@tomcat ~]# tar xvf apache-tomcat-10.0.23.tar.gz -C /opt/tomcat/ --strip-components=1
apache-tomcat-10.0.23/conf/
apache-tomcat-10.0.23/conf/catalina.policy
apache-tomcat-10.0.23/conf/catalina.properties
apache-tomcat-10.0.23/conf/context.xml
apache-tomcat-10.0.23/conf/jaspic-providers.xml
apache-tomcat-10.0.23/conf/jaspic-providers.xsd
apache-tomcat-10.0.23/conf/logging.properties
apache-tomcat-10.0.23/conf/server.xml
apache-tomcat-10.0.23/conf/tomcat-users.xml
apache-tomcat-10.0.23/conf/tomcat-users.xsd
apache-tomcat-10.0.23/conf/web.xml
apache-tomcat-10.0.23/bin/
apache-tomcat-10.0.23/lib/
apache-tomcat-10.0.23/logs/
apache-tomcat-10.0.23/temp/

Step 11: Now give the ownership permission to the directory by using the below command

[root@tomcat ~]# chown -R tomcat:tomcat /opt/tomcat/

Step 12: Give the execute permission to the directory and enable the scripts in the directory by using the below command

[root@tomcat ~]# sh -c 'chmod +x /opt/tomcat/bin/*.sh'

Step 13: Create a systemd file for start and stop Apache Tomcat by using the below command

[root@tomcat ~]# vim /etc/systemd/system/tomcat.service
Add the content in the file
[Unit]
Description=Apache Tomcat Web Application Container
Wants=network.target
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1G -Djava.net.preferIPv4Stack=true'
Environment='JAVA_OPTS=-Djava.awt.headless=true'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
SuccessExitStatus=143
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always



[Install]
WantedBy=multi-user.target

Step 14: Reload the daemon service by using the below command

[root@tomcat ~]# systemctl daemon-reload 

Step 15: Start the tomcat service by using the below command

[root@tomcat ~]# systemctl start tomcat.service 

Step 16: Enable the Tomcat service by using the below command

[root@tomcat ~]# systemctl enable tomcat.service 
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

Step 17: Check the status of Tomcat service by using the below command

[root@tomcat ~]# systemctl status tomcat.service 
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-09-01 16:43:53 EDT; 18s ago
 Main PID: 40640 (java)
    Tasks: 28 (limit: 17274)
   Memory: 133.2M
   CGroup: /system.slice/tomcat.service
           └─40640 /usr/lib/jvm/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf

Step 18: Configure Tomcat Web Management by using the below command

[root@tomcat ~]# vim /opt/tomcat/conf/tomcat-users.xml
Change the user name and password of this file 
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="admin" password="Linuxc#5" roles="tomcat,role1"/>
  <user username="admin" password="Linuxc#5" roles="role1"/>
-->

Step 19: Allow Tomcat to be accessible remotely both for manager and host manager by using the below command

For manager
[root@tomcat ~]# vim /opt/tomcat/webapps/manager/META-INF/context.xml

-->
<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.6.122" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

For host manager
vim /opt/tomcat/webapps/host-manager/META-INF/context.xml
-->
<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.6.122" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

Step 20: Add the firewall for port 8080 by using the below command

[root@tomcat ~]# firewall-cmd --add-port=8080/tcp --permanent 
Success

Step 21: List the default zone to check by using the below command

[root@tomcat ~]# firewall-cmd --permanent --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: cockpit dhcpv6-client ssh

  ports: 8080/tcp
  protocols: 
  forward: no
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

Step 22: Reload the firewall by using the below command

[root@tomcat ~]# firewall-cmd --reload 
Success

Step 23: Go to the browser and search your server IP with port 8080 as shown in the below image snap 1

Output

This is the welcome page of tomcat snap 2

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Apache Tomcat in Rocky Linux 8.6. Your feedback is much welcome.

Tags:
muhammad
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What does Java Servlet do in Apache Tomcat?

A

A Java Servlet is a java software component that extends the capabilities of a server in Apache Tomcat.

Q

What is the main purpose of Java servlets in Apache Tomcat?

A

The main purpose of the java servlets is for sending content to a client which generates dynamic content on the web in Apache Tomcat.

Q

Why do we need JSPs in Apache Tomcat?

A

We need JSPs which is easy to code and read in Apache Tomcat

Q

Is JSP a server-side Scripting language in Apache Tomcat?

A

Yes, JSP is a server-side Scripting language in Apache Tomcat.

Q

Does Tomcat use an Apache HTTP server?

A

Tomcat is primarily an application server, which serves requests to custom-built Java servlets or JSP files on your server.

Related Tutorials in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

Related Tutorials in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to use Aureport command on Linux
How to use Aureport command on Linux
Nov 28, 2017
How to install Development tools on Linux
How to install Development tools on Linux
Jun 12, 2018
How to Install mod_ssl and SSL certificate on Oracle Linux
How to Install mod_ssl and SSL certificate on Oracle Linux
Dec 30, 2021
How to install Nextcloud on Ubuntu 22.04 version
How to install Nextcloud on Ubuntu 22.04 version
Jun 23, 2023
How to install ClipGrab in Linux
How to install ClipGrab in Linux
Jul 16, 2016

Related Forums in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

Related Forums in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

Related News in How to install and configure Apache Tomcat 10 in Rocky Linux 8.6

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.