Install Tomcat 9 on RHEL 8

Install open JDK

dnf install java-11-openjdk-devel

Download tomcat

https://tomcat.apache.org/download-90.cgi

Under Deployer rightclick tar.gz and copy the URL

It will be similar to: https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.87/bin/apache-tomcat-9.0.87.tar.gz
On Unix server use wget to download the s/w using URL just copied

cd /var/tmp
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.87/bin/apache-tomcat-9.0.87.tar.gz
unzip download : gunzip /var/tmp/apache-tomcat-9.0.87.tar.gz

Copy tar file to /usr/local

mv apache-tomcat-9.0.87.tar /usr/local

Extract tar file

cd /usr/local
tar -xvf apache-tomcat-9.0.87.tar


rename tomcat s/w dir

mv apache-tomcat-9.0.87 tomcat9


Add tomcat user

useradd -r tomcat


update tomcat s/w ownership

chown -R tomcat:tomcat /usr/local/tomcat9


Add tomcat service

vi /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment=CATALINA_PID=/usr/local/tomcat9/temp/tomcat.pid
Environment=CATALINA_HOME=/usr/local/tomcat9
Environment=CATALINA_BASE=/usr/local/tomcat9

ExecStart=/usr/local/tomcat9/bin/catalina.sh start
ExecStop=/usr/local/tomcat9/bin/catalina.sh stop

RestartSec=12
Restart=always
[Install]
WantedBy=multi-user.target

Reload and Enable new Service

systemctl daemon-reload
systemctl start tomcat.service
systemctl enable tomcat.service
systemctl status tomcat.service

check Tomcat URL works

http://127.0.0.1:8080