Tomcat 10.1.x Installation

System Update and Package Installation

 

Update Package List

# apt update

 

Upgrade All Packages

# apt upgrade -y

 

Java Installation

 

Install OpenJDK 11

# apt install openjdk-11-jdk

 

Verify Java Installation

# java -version

 

Create Tomcat User

For security reasons, create a new user for the Tomcat server.

 

Create Tomcat Group

# groupadd tomcat

 

Create Tomcat User

# useradd -g tomcat -d /opt/tomcat -s /bin/false tomcat

 

Download and Install Tomcat

 

Download Tomcat 10.1.x

# wget <link>

 

Create Directory for Tomcat

# mkdir /opt/tomcat

 

Unzip Tomcat Archive to /opt/tomcat

# tar xzvf apache-tomcat-10.1.25.tar.gz -C /opt/tomcat --strip-components=1

 

Change Ownership of Tomcat Directory

# chown -R tomcat: /opt/tomcat

 

Set Appropriate Permissions for Tomcat Directory

# chmod -R u+rwx /opt/tomcat




Create Tomcat Service File

Create a systemd service file to manage Tomcat as a service.

 

Create and Edit Tomcat Service File

# vim /etc/systemd/system/tomcat.service



Add the Following Script

[Unit]

Description=Apache Tomcat 10 Web Application Container

After=network.target

 

[Service]

Type=forking

 

User=tomcat

Group=tomcat

 

Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"

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/t



Enable and Start Tomcat Service

Reload the systemd daemon and start the Tomcat service:

 

 Reload systemd daemon

# systemctl daemon-reload

 

Start Tomcat service

# systemctl start tomcat

 

Enable Tomcat to start on boot

# systemctl enable tomcat



Configure Firewall

Ensure the firewall is configured to allow traffic on Tomcat's default port (8080):

 

Allow traffic on port 8080

# ufw allow 8080/tcp

 

Reload the firewall to apply changes

# ufw reload

 

 





  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to add IP Address to servers

1.Login to the server via RDP. 2.In the Run window type NCPA.CPL. 3.In the network properties...

How to configure IP's on Ubuntu 18?

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant...

How to install Wordpress in webmin

  The following steps are followed for installing Wordpress in Webmin   Open File Manager in...

How to install Webmin in CentOs

  Installing webmin using YUM repository Create a .repo file using a command # nano...

How to install Virtualmin in webmin

  Steps for Installing Virtualmin on Webmin (Ubuntu):   Setting the hostname and FQDN For...

Powered by WHMCompleteSolution