How to Install (*Tomcat*) in Ubuntu 20.04 LTS/19.10?

T

omcat: Apache Tomcat is a servlet container and web server that is utilized to serve Java applications. It is a free and open-source implementation released by the Apache Software Foundation. Tomcat has a strong ecosystem of add-ons and it is easy to use. Here, we will explain to you how to install Tomcat on Ubuntu 20.04 LTS/19.10 in an easy and simple manner.

Index:

Installing Tomcat on Linux Ubuntu 20.04 LTS/19.10:

Make sure you logged in as a root user or a user with Sudo privileges.

Install Java:

Before installing Tomcat, we have to install Java as it requires to be installed on the server. We will install OpenJDK which is a default Java development in Ubuntu 18.04 LTS Bionic Beaver.

  • Use this keyboard shortcut CTRL+ALT+T to open the Terminal on Linux Ubuntu.
  • You have to execute the following commands one by one in the Terminal.
  • Copy and paste the below command and click Enter.
  • Type your system password when it is prompted.

Update the Package Index:

To install OpenJDK Package:

$
sudo apt install default-jdk

Creating a Tomcat User:

Tomcat has to run as a non-privileged user (non-root) due to security reasons. So we have to create a user and group that will run the Tomcat service.

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

Install Tomcat:

At the time of writing this tutorial, the latest version of Tomcat is 9.0.27 so we are going to install it here.

Download the Tomcat Archive:

$
wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz -P /tmp

Extract the Tomcat Archive:

$
sudo tar xf /tmp/apache-tomcat-9*.tar.gz -C /opt/tomcat

Create a Symbolic Link:

$
sudo ln -s /opt/tomcat/apache-tomcat-9.0.27 /opt/tomcat/latest

Change the Directory Ownership:

$
sudo chown -RH tomcat: /opt/tomcat/latest

For Executable Flag:

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

Start the Tomcat Service:

$
sudo systemctl start tomcat

Check the Service Status of Tomcat:

$
sudo systemctl status tomcat

Enable the Tomcat service:

$
sudo systemctl enable tomcat

Restart Tomcat service:

To restart the Tomcat service, you have to run the below command:

$
sudo systemctl restart tomcat

Closure:

We hope that this tutorial assisted you on how to install Tomcat on Linux Ubuntu 20.04 LTS Focal Fossa/19.10 Eoan Ermine clearly. We have explained the installation with clear-cut steps so it will help you the best. Your valuable comments/feedback are highly encouraged as it will be an asset to our write-up. Thanks for visiting Tec Robust Stay tuned for more interesting articles!!

Related Articles:



Leave a Reply

Need Help? Chat with us