“How to Install Tomcat 9 on Ubuntu 20.04”

Maneesh kushwaha
4 min readMay 30, 2020

--

Install Tomcat 9 on Ubuntu 20.04”

“How to Install Tomcat 9 on Ubuntu 20.04”

We hope this post helped you to find out “How to Install Tomcat 9 on Ubuntu 20.04”

Reading full article here https://www.mstvlife.com/how-to-install-tomcat-9-on-ubuntu-20-04

This tutorial describes how one can set up and configure Tomcat 9 on Ubuntu 20.04.

Apache Tomcat is an open-source internet server and Java servlet container. It is among the hottest selections for constructing Java-based web sites and functions. Tomcat is light-weight, straightforward to make use of, and has a sturdy ecosystem of add-ons.

Installing in Java #

Tomcat 9 requires Java SE eight or later to be put in on the system. We’ll set up OpenJDK 11, the open-source implementation of the Java Platform.

Run the next instructions as root or consumer with sudo privileges or root to replace the packages index and set up the OpenJDK 11 JDK bundle:

sudo apt update
sudo apt install openjdk-11-jdk

As soon as the set up is full, confirm it by checking the Java model:

java -version

The output should look something like this:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Making a System Person #

Working Tomcat beneath the basis consumer is a safety danger. We’ll create a brand new system consumer and group with residence listing /decide/tomcat that may run the Tomcat service. To take action, enter the next command:

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

Downloading Tomcat #

Tomcat binary distribution is obtainable for obtain from the Tomcat downloads page.

Reading full article here https://www.mstvlife.com/how-to-install-tomcat-9-on-ubuntu-20-04

On the time of writing, the most recent Tomcat model is 9.0.35. Earlier than persevering with with the subsequent step, verify the Tomcat 9 obtain web page to see if a more recent model is obtainable.

Use wget to obtain the Tomcat zip file to the /tmp listing:

VERSION=9.0.35 wget https://www-eu.apache.org/dist/tomcat/tomcat-9/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz -P /tmp

Once the download is complete, extract the tar file to the /opt/tomcat directory::

sudo tar -xf /tmp/apache-tomcat-${VERSION}.tar.gz -C /opt/tomcat/

Tomcat is up to date frequently with safety patches and new options. To have extra management over variations and updates, we’ll create a symbolic hyperlink known as newest, that factors to the Tomcat set up listing:

sudo ln -s /opt/tomcat/apache-tomcat-${VERSION} /opt/tomcat/latest

Later, when upgrading Tomcat, unpack the newer model and alter the symlink to level to it.

The system consumer that was beforehand created will need to have entry to the tomcat set up listing. Change the directory ownership to consumer and group tomcat:

sudo chown -R tomcat: /opt/tomcat

The shell scripts inside the Tomcat’s bin directory must be executable:

sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'

These scripts are used to start, stop and, otherwise manage the Tomcat instance.

Creating SystemD Unit File #

Instead of using the shell scripts to start and stop the Tomcat server, we’ll set it to run as a service.

Open your text editor and create a tomcat.service unit file in the /etc/systemd/system/ directory:

sudo nano /etc/systemd/system/tomcat.service

Paste the following configuration:

/etc/systemd/system/tomcat.service[Unit]
Description=Tomcat 9 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target

Modify the JAVA_HOME variable if the path to your Java installation is different.

Reading full article here https://www.mstvlife.com/how-to-install-tomcat-9-on-ubuntu-20-04

Save and close the file and notify systemd that a new unit file exists:

sudo systemctl daemon-reload

Enable and start the Tomcat service:

sudo systemctl enable --now tomcat

Check the service status:

sudo systemctl status tomcat

The output should show that the Tomcat server is enabled and running:

● tomcat.service - Tomcat 9 servlet container
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-05-25 17:58:37 UTC; 4s ago
Process: 5342 ExecStart=/opt/tomcat/latest/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 5362 (java)
...

You can start, stop and restart Tomcat same as any other systemd service:

sudo systemctl start tomcat
sudo systemctl stop tomcat
sudo systemctl restart tomcat

Configuring Firewall #

In case your server is protected by a firewall and also you wish to entry Tomcat from the surface of your native community, you’ll want to open port 8080.

Use the next command to open the required port:

Reading full article here https://www.mstvlife.com/how-to-install-tomcat-9-on-ubuntu-20-04/

Conclusion #

We’ve proven you how one can set up Tomcat 9.Zero on CentOS eight and how one can entry the Tomcat administration interface.

For extra details about Apache Tomcat, go to the official documentation page.

We hope the “How to Install Tomcat 9 on Ubuntu 20.04” help you. If you have any query regarding “How to Install Tomcat 9 on Ubuntu 20.04″drop a comment below and we will get back to you at the earliest.

We hope this post helped you to find out “How to Install Tomcat 9 on Ubuntu 20.04” . You may also want to see — How to Install Anaconda on CentOS 8

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response