How To Install Apache Tomcat Server On Ubuntu 22.04
How To Install Apache Tomcat Server On Ubuntu 22.04
04
The Apache Software Foundation developed and maintains the open
source web server for Java programs known as Apache Tomcat. Its
purpose is to host and distribute Java servlets, which are server-side Java
code snippets responsible for managing HTTP responses from client
Java applications.
Further, Apache Tomcat functions as a web server, providing critical
web server processing capabilities for the relevant servlets, rather than
an entire application server with features such as load balancing and data
persistence. Additionally, it supports the init(), service(), and
destroy() methods as part of the Java servlet lifecycle.
Next, download the latest version of Apache Tomcat from its official
website using the following command.
wget
https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.
20/bin/apache-tomcat-10.0.20.tar.gz
Next, move the content of the extracted directory to the Apache Tomcat
home directory.
mv apache-tomcat-10.0.20/* /opt/tomcat
[Service]
Type=forking
Environment=JAVA_HOME=/opt/jdk-17.0.9
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=CATALINA_TMPDIR=/opt/tomcat/temp
Environment="CATALINA_OPTS=-Xms64M -Xmx1024M -server -
XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
ExecReload=/bin/kill $MAINPID
RemainAfterExit=yes
# Security
User=tomcat
Group=tomcat
PrivateTmp=yes
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
CacheDirectory=tomcat10mm
CacheDirectoryMode=750
ReadWritePaths=/opt/tomcat/conf/
ReadWritePaths=/opt/tomcat/webapps/
ReadWritePaths=/opt/tomcat/logs/
[Install]
WantedBy=multi-user.target
Save and close the file then reload the systemd daemon to apply the
changes.
systemctl daemon-reload
Next, start the Apache Tomcat service and enable it to start at system
reboot with the following command.
systemctl enable --now tomcat
Also check the status of the Apache Tomcat service with the following
command.
systemctl status tomcat
Save and close the file when you are done. Then, restart the Tomcat
service to implement the changes.
systemctl restart tomcat
Access Apache Tomcat
Now, Apache Tomcat is installed on your server. Access it using the
URL http://your-server-ip:8080 on your web browser. You
should see the Tomcat dashboard on the following screen.