Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Installing Tomcat

Welcome to this hands-on lab for installing Tomcat 9 onto Red Hat Enterprise 8. Apache's Tomcat is a Java based application platform built around deploying and managing Java Web Applications. Tomcat is cross-platform, working on anything that supports Java, but this hands-on lab focuses on a Red Hat 8 deployment. In it we will configure the system and install Tomcat version 9. Once we have Tomcat installed, we will configure it with a user and then configure it so we can access the management web console via the internet.

Google Cloud Platform icon

Path Info

Clock icon Beginner
Clock icon 45m
Clock icon May 08, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Install Java 11 OpenJDK

    You need to install the java-11-openjdk-devel package:

    sudo dnf install java-11-openjdk-devel

    Once it's installed, check the version of Java to ensure it has installed properly and is set as the default for the system.

  2. Challenge

    Obtain Tomcat version 9 from the Apache Tomcat Website

    Go to the webpage to get the latest version of Tomcat 9:

    Go to the Binary Distributions section.
    Under the Core section, right click on the tar.gz, then select Copy Link Location.

    Now use wget to download the file:

  3. Challenge

    Install and Configure Tomcat, Create the User and Service, Then Start It and Ensure It Starts on a System Reboot

    You need to expand the compressed Tomcat files into the location it will be put.

    Change to the root user (or add 'sudo' at the beginning of the commands that follow)

    sudo su -

    Change to the location we will use for the tomcat files.

    cd /usr/local

    Extract the downloaded file to the current location. Note: replace THE-TOMCAT-FILE-YOU-COPIED-EARLIER with the correct file that was downloaded.

    tar -xvf /home/cloud_user/THE-TOMCAT-FILE-YOU-COPIED-COPIED-EARLIER

    Change the name of the Tomcat folder to tomcat9. Note the version you get may be newer than this one. Change the name as needed:

    mv apache-tomcat-9.0.31 tomcat9

    Add the tomcat user as a system account:

    useradd -r tomcat

    Change the permissions of the tomcat9 folder so the tomcat user can use it:

    chown -R tomcat:tomcat /usr/local/tomcat9

    Create the tomcat service. Use an editor (like Vim) to create a file /etc/systemd/system/tomcat.service:

    vim /etc/systemd/system/tomcat.service

    Add the following contents (and note that if you copy and paste whats below, ensure the lines in your file do not have leading spaces):

    Description=Apache Tomcat
    ExecStart=/usr/local/tomcat9/bin/ start
    ExecStop=/usr/local/tomcat9/bin/ stop

    Next we need to have the system recognize there is a new service. We can use the daemon-reload option for systemctl:

    systemctl daemon-reload

    Now we can start the service, set it to restart on system boot, and check if it's currently running:

    systemctl start tomcat.service
    systemctl enable tomcat.service
    systemctl status tomcat.service

    Check that Tomcat works by going to your server's public IP address, on port 8080, in a web browser:

  4. Challenge

    Add an admin User for Tomcat

    To add an admin user for Tomcat, you need to edit the tomcat-users.xml file:

    cd /usr/local/tomcat9/
    vim conf/tomcat-users.xml

    Go to the bottom of the file, and put the following just before the </tomcat-users> end block. Don't forget to change the YOURPASSWORDHERE to be your own password, whatever you like:

    <role rolename="admin-gui,manager-gui"/> 
    <user username="admin" password="YOURPASSWORDHERE" roles="admin-gui,manager-gui"/>
  5. Challenge

    Modify Tomcat so You Can Log in Remotely

    The next step is to allow access to the management web pages from the internet.

    Edit the webapps/manager/META-INF/context.xml file:

    vim webapps/manager/META-INF/context.xml

    Get to the following line:

    allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

    Change it to this:

    allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1 |.*" />
  6. Challenge

    Restart Tomcat and Check Remote Connectivity

    The next task is to restart the Tomcat and ensure it is accessible, then try logging in:

    systemctl restart tomcat

    Go to the public IP address of the lab server and test out logging in via the port 8080.

    Check that Tomcat works by going to your server's web page on port 8080


    Log in with the username and password you completed on Step 5: Add an admin User for Tomcat

    You should be able to log in and manage the Tomcat installation.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans