Introduction
Apache Tomcat is an open-source Servlet Container that runs Java applications. It supports the Java Servlet, JavaServer Pages (JSP), and WebSocket technologies, making it suitable for deploying dynamic web applications. Tomcat is an open source Java Servlet container lightweight, flexible and Most Popular in the world for hosting java-based web service and Enterprise Applications..
Prerequisites
- 1 Core CPU and 1 GB Memory
- 2 GB disk space (This will be a minimal requirement, Click here for offical website.)
In this post, We are going to show you how to install Apache Tomcat 10 on Ubuntu 24.04 LTS.
Step 1: Run System Update & Upgrade
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
sudo apt-get update && sudo apt-get upgrade -yStep 2: Installing JAVA 11
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
sudo apt-get install openjdk-11-jdk -yjava -versionStep 3: Crearting Tomcat User and Group
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
To add the group.
sudo groupadd tomcatsudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcatStep 4: Downloading Apache Tomcat 10
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
To change diretory
cd /tmpTo install curl utility if needed.
sudo apt-get install curl -ycurl -O curl -O https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.34/bin/apache-tomcat-10.1.34.tar.gzStep 5: Extrating Apacha Tomcat 10
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
To make tomcat directory.
sudo mkdir /opt/tomcatsudo tar xzvf apache-tomcat-10*tar.gz -C /opt/tomcat --strip-components=1cd /opt/tomcatsudo chgrp -R tomcat /opt/tomcatsudo chmod g+x confsudo chown -R tomcat webapps/ work/ temp/ logs/Step 6: Finding JAVA PATH
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
sudo update-java-alternatives -lStep 7: Run System Update & Upgrade
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
sudo nano /etc/systemd/system/tomcat.service[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.targetStep 8: Controlling Apache Tomcat Service
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
To reload the new added service for tomcat.
sudo systemctl daemon-reloadsudo systemctl start tomcatsudo systemctl status tomcatsudo systemctl enable tomcatStep 9: Allowing Ports in UFW
We need to execute the given command that updates and upgrades the Ubuntu repository and upgrades the packages.
sudo ufw allow 8080sudo ufw allow 8443