Skip to main content

Tomcat on a Different Port

Hands-On Lab

 

Photo of

Training Architect

Length

00:30:00

Difficulty

Intermediate

Welcome to this hands-on lab, where we'll change the default port used by Apache's Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The server provided in this lab environment is Red Hat Enterprise 8 and has Tomcat 9 pre-installed for you. The Tomcat instance is currently available for you on port 8080, on the provided server.

You will log into the server and change the port used to be 8081.

Once you have completed the task you will need to test the new port works by connecting to it with a web browser.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Tomcat on a Different Port

Introduction

Welcome to this hands-on lab, where we'll change the default port used by Apache's Tomcat, a Java-based application platform built around deploying and managing Java Web Applications. The server provided in this lab environment is Red Hat Enterprise 8 and has Tomcat 9 pre-installed for you. The Tomcat instance is currently available for you on port 8080, on the provided server.

You will log into the server and change the port used to be 8081.

Once you have completed the task you will need to test the new port works by connecting to it with a web browser.

The Scenario

Your manager wants to use other software on your servers that use port 8080. Since that is the default port for Tomcat, you have been asked to set up a test system that uses a different port. The server is already configured, but you have been tasked with doing what is required to get it up and running on port 8081.

Perform the tasks as mentioned in the tasks list.

A successful hands-on lab will have you able to see the Tomcat GUI on the server via the new port of 8081.

Note: It may take 3 to 10 minutes after the hands-on lab has started before you are able to log into the server. This is fine and will not affect the performance of the tasks for the hands-on lab.

Logging In

Use the credentials provided on the hands-on lab overview page, and log in to the provided server as cloud_user. Note that this is for connecting to the server, not the Tomcat GUI. Once you are logged in, become root by running sudo su -.

Change the Tomcat Port to 8081

The file we need to edit is /usr/local/tomcat9/conf/server.xml. Let's get into a directory near it:

cd /usr/local/tomcat9/

Now we'll edit the file (using vim in this example):

vim conf/server.xml

Find the following portion:

<Connector port="8080"

Then replace it with the following:

<Connector port="8081"

Save the file and exit.

Restart the Tomcat Server and Check for Any Errors

Restart the Tomcat server. This can be done with the following command:

systemctl restart tomcat

Connect to the Tomcat GUI via the New Port

If there were no errors, we can use a web browser and try connecting to Tomcat (at the same IP address we used for SSH access) on port 8081. If your server's IP address was 3.93.186.99, then you would use the following (Note: Your IP address will likely be different):

http://3.93.186.99:8081

You should now see the Tomcat GUI. This shows your change was successful.

Conclusion

We've got Tomcat running on port 8081. Now your manager can run his other applications on 8080. Congratulations on completing the hands-on lab!.