How to install Tomcat on Ubuntu and derivatives?

apache-tomcat

Tomcat is an open source server application for Linux, Windows and other operating systems that are designed to run Java Serverlet containers, and can also run Java Server Page technology.

Tomcat is a web container with servlet and JSP support. Tomcat is not an application server, like JBoss or JOnAS.

Can function as a web server by itself. Tomcat is developed and updated by members of the Apache Software Foundation and independent volunteers.

Users have free access to its source code and its binary form under the terms established in the Apache Software License.

The most recent versions are 9.x, which implement the Servlet 4.0 and JSP 2.3 specifications.

Tomcat installation on Ubuntu and derivatives

Given that Tomcat was writtenito in Java, it works on any operating system that has the Java virtual machine.

It includes the Jasper compiler, which compiles JSPs into servlets. The Tomcat servlet engine is often featured in conjunction with the Apache web server.

In this guide, we will see how to install Apache Tomcat version 9 in Ubuntu, although these commands also apply to any other derivative of Ubuntu.

Configure java

Apache Tomcat is a Java server, so it is not possible to use the software without installing Java first.

Fortunately, there is a PPA for Ubuntu that removes the difficulty of getting a working version of the Java runtime environment.

To add the PPA to your system, They must open a terminal and in it we are going to type the following command:

sudo add-apt-repository ppa: webupd8team/java

After adding the PPA to Ubuntu we proceed to refresh our list with:

sudo apt update

And finally we can install java with this command:

sudo apt install oracle-java8-installer

Java environment is not configured automatically for use when installed. So they must configure Java by adding things to the / etc / environment file.

In order to perform this operation we are going to execute the following command:

sudo nano -w /etc/environment

Now, we must scroll to the bottom of the content of the file and in this we are going to place the following:

JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre"

Once the change is made, we can save the modifications by pressing Ctrl + O and to close the editor they do so by pressing Ctrl + X.

Once the environment is established, we need to edit the Bashrc file and set the path for Java.

nano -w ~/.bashrc

Navigate to the bottom of the file and add the following code to the Bashrc file.

# Java Path

export JAVA_HOME = / usr / lib / jvm / java-8-oracle / jre

export PATH = JAVA_HOME / bin: $ PATH [/ sourcecode]

We save and exit the file and then we are going to execute the following command:

source ~/.bashrc

Once this is done, it is recommended that we restart our computer so that the changes we have just made take effect.

Apache Tomcat Installation

tomcat-status

Once our computer has restarted, now we are going to proceed to install Tomcat in our system, for this we are going to open a terminal and in it we are going to type the following:

wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.13/bin/apache-tomcat-9.0.13.tar.gz

Once the download is done, now we are going to copy the content to the opt folder:

sudo -s

mkdir -p /opt/tomcat

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

Now we proceed to create a user and a group:

groupadd tomcat

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

And we are going to give the user permissions with:

chown -R tomcat:tomcat /opt/tomcat

We give permissions to the files in the Tomcat directory so that these are executable:

cd /opt/tomcat/bin

chmod + x *

Open the Bashrc file one last time with:

nano -w ~/.bashrc

Once the file is open add the following code to the end of the file.

#Catalina

export CATALINA_HOME=/opt/Tomcat

We save and close the file and then execute:

source ~/.bashrc

Finally, start the server by executing the following command:

sudo $CATALINA_HOME/bin/startup.sh

To stop the Tomcat server, run:

sudo $CATALINA_HOME/bin/shutdown.sh

Access the Apache Tomcat server

Tomcat opens by default on port 8080, so to access it, they will have to look for the local IP address of the server and access the following URL in a web browser.

http://tu-ip: 8080

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   linux2 said

    I run the command sudo $ CATALINA_HOME / bin / startup.sh
    and the following error comes out
    sudo: /bin/startup.sh: command not found
    what is this about

  2.   Andrew said

    export CATALINA_HOME = / opt / Tomcat

    the error is in the T ... change it to