Downloading and Installing Apache Tomcat

To install Apache Tomcat:

  1. (Optional) It is recommended to update the system with the latest security patch.

›_ Console

# dnf -y update
  1. Install OpenJDK for Java 17.

›_ Console

# dnf -y install java-17-openjdk java-17-openjdk-devel 
  1. Create a non-root user and set its password.

›_ Console

# useradd tomcat  
# passwd tomcat 
  1. Download Tomcat 11.

›_ Console

# wget https://dlcdn.apache.org/tomcat/tomcat-11/v11.0.21/bin/apache-tomcat-11.0.21.tar.
  1. Create a directory.

›_ Console

# mkdir -p /opt/tomcat
  1. Extract the archived file to the /opt/tomcat directory.

›_ Console

# tar -xvf apache-tomcat-11.0.21.tar.gz -C /opt/tomcat --strip-components=1
  1. Change ownership of the /opt/tomcatdirectory to the Tomcat user.

›_ Console

# chown -R tomcat:tomcat /opt/tomcat 
  1. Set executable permissions to scripts.

›_ Console

# chmod +x /opt/tomcat/bin/*.sh 
  1. Create Apache Tomcat systemd file /etc/systemd/system/tomcat.service to manage the Tomcat service through systemctl and add below lines.

›_ Console

[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 


Change the values according to your system configuration.

image-20260422-110507.png


tomcat.service File Output

  1. Reload the daemon using:

›_ Console

# systemctl daemon-reload
  1. Start and enable the Tomcat service.

›_ Console

# systemctl start tomcat 
# systemctl enable tomcat 
  1. Confirm that the Tomcat status is running using:

›_ Console

# systemctl status tomcat 
image-20260422-091944.png


Tomcat Service Status

13. Open http://<apache_tomcat_server-ip>:8080, in any web browser and verify that the Apache Tomcat page is visible.

tomcat success page-20260414-084755.jpg


Browser Output Over Page 8080