Apache Tomcat is a popular open-source web server and servlet container developed by the Apache Software Foundation. It is used to deploy Java-based web applications and provides a platform for Java servlets and Java Server Pages (JSPs) to run. In this blog, we’ll show you how to install Tomcat on Linux server.

What is Apache Tomcat?

Apache Tomcat is a widely-used implementation of the Java Servlet and JavaServer Pages (JSP) technologies. It provides a robust platform for web application development and deployment, offering a number of features that make it ideal for use in a variety of different environments.

Features of Apache Tomcat

  1. Lightweight: Tomcat is designed to be lightweight and fast, making it ideal for use on servers with limited resources.
  2. Scalability: Tomcat is highly scalable, allowing it to support large-scale web applications with ease.
  3. Modular Architecture: Tomcat is designed to be highly modular, allowing you to add or remove components as needed to meet your specific needs.
  4. Cross-Platform Support: Tomcat is available for a variety of platforms, including Windows, Linux, and macOS, making it easy to deploy in a variety of different environments.
  5. Easy Configuration: Tomcat offers a simple and straightforward configuration process, allowing you to get up and running quickly and easily.

Tomcat versions, Release Dates, EOL and Java compatibility:

Here I am listing Apache Tomcat versions, its released date, EOL and Java compatibility so you will get idea to install most updated version for your Linux server.

VersionsReleased DatesEOLJava compatibility
10.123 Sep 2022TBD11+
10.003 Dec 202031 Oct 20228+
927 Sep 2017TBD8+
8.517 Mar 201631 Mar 20247+
8.029 Jan 201430 Jun 20187+
Tomcat versions, Release Dates, EOL and Java compatibility

Steps to install Apache Tomcat on Linux server

Latest Apache Tomcat doesn’t come with installation package. The best way to install Apache Tomcat is to download their binaries from Apache official websites. This tutorial will help you to install latest Apache Tomcat on Linux servers like CentOS, RHEL, Oracle Linux, Rocky Linux, AlmaLinux, Ubuntu or Debian.

Apache Tomcat installation on linux server
Apache Tomcat installation on Linux server

Prerequisites:

  • sudo privileges.
  • Stable internet connection.
  • Latest JAVA. Click here for JAVA installation.
  • Enable required ports in firewall

Install the prerequisites:

For RHEL, CentOS and Oracle Linux 7 server
# yum install wget gzip -y

For RHEL, CentOS, Oracle Linux or Rocky Linux 8 and 9 server
# dnf install wget gzip -y

For Ubuntu and Debian server
# apt install wget gzip -y

Now download Apache Tomcat from Official website:

# cd /opt && wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.5/bin/apache-tomcat-10.1.5.tar.gz

create a tomcat user and group:

# useradd -m -U -d /opt/tomcat -s /bin/false tomcat

Extract downloaded tar file and delete tar file:

# tar -xvzf apache-tomcat-*tar.gz -C /opt/tomcat --strip-components=1 && rm -rf apache-tomcat-*.tar.gz

Change the ownership of /opt/tomcat directory:

# chown -R tomcat:tomcat /opt/tomcat
# sh -c 'chmod +x /opt/tomcat/bin/*.sh'

Create Systemd Service for Tomcat service:

# cat <<'EOT' | sudo tee /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
EOT

Reload Systemd configuration changes and start Tomcat service:

# systemctl daemon-reload
# systemctl start tomcat.service

Access Apache Tomcat:
Note : Need to enable Port 8080 in the firewall.

URL: http://server_ip_address:8080

Managing Apache Tomcat service

let’s review some basic management commands.

Verify installed version of Tomcat:

# /opt/tomcat/bin/version.sh

Check status of the Tomcat service:

# systemctl status tomcat.service

Restart the Tomcat service:

# systemctl restart tomcat.service

If you want to stop ATomcat service:

# systemctl stop tomcat.service

Apache Tomcat service is disabled to start automatically when the server boots. If you want to enable it at startup, run:

# systemctl enable tomcat.service

Disable the service to start up at boot:

# systemctl disable tomcat.service

Uninstall Apache Tomcat from Linux server

To completely remove Apache Tomcat from a system, you must remove the Tomcat applications, the configuration files, and any directories containing data.

Warning: This process will completely remove Apache Tomcat and its configuration. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.

# systemctl stop tomcat.service && systemctl disable tomcat.service
# rm -rf /opt/tomcat

Conclusion

Congratulations! We’ve installed Apache Tomcat on Linux system like CentOS, RHEL, Rocky Linux, AlmaLinux, Ubuntu and Debian. We hope this 2 minutes stuff helped you and thank you for visiting our website.
Cheers!!!