Skip to content

Guide to Setting Up Apache Tomcat 11.0.7 in Combination with Nginx on Ubuntu 24.04 Operating System

Guide for setting up Apache Tomcat 11.0.7 alongside Nginx on Ubuntu 24.04, aimed at optimizing Java web application hosting. Follow this comprehensive walkthrough.

Installing Apache Tomcat 11.0.7 alongside Nginx on Ubuntu 24.04: A Step-by-Step Guide
Installing Apache Tomcat 11.0.7 alongside Nginx on Ubuntu 24.04: A Step-by-Step Guide

Guide to Setting Up Apache Tomcat 11.0.7 in Combination with Nginx on Ubuntu 24.04 Operating System

In this article, we will guide you through the process of setting up a reliable and high-performing environment for deploying Java web applications using Apache Tomcat 11.0.7 and Nginx on Ubuntu 24.04 LTS.

Prerequisites

Before we begin, ensure you have the following prerequisites in place:

  1. A fresh Ubuntu 24.04 LTS server
  2. A non-root user with sudo privileges
  3. OpenJDK 17 installed (required to run Tomcat)

Setting Up the Environment

  1. Installing Nginx: Run and . Once installed, enable Nginx to start on boot with .
  2. Configuring Nginx: Create a custom Nginx configuration file, , and define upstream Tomcat servers, proxy rules, and SSL settings using Let's Encrypt SSL.
  3. Installing Certbot: For automatic SSL, install Certbot with .
  4. Obtaining a Certificate: Run to obtain a certificate for your domain.
  5. Configuring Firewall: Open HTTP and HTTPS ports for Nginx and Certbot usage, and allow traffic to the Tomcat web interface on port 8080.
  6. Creating a Tomcat System User: Create a user specifically for Tomcat with .
  7. Downloading and Extracting Tomcat: Download Tomcat 11.0.7, extract it to , and set the owner to the Tomcat user.
  8. Configuring Tomcat: Update the Tomcat server.xml file to reflect the correct ports, paths, and security settings.
  9. Creating a Systemd Service File for Tomcat: Create a systemd service file for Tomcat, enable it, and set it to start on boot.
  10. Securing the Environment: Follow best practices for securing both servers, including keeping Tomcat updated, configuring Nginx to block direct access to Tomcat's port, securing admin interfaces, using UFW or iptables to limit open ports, hardening both servers, and rotating logs and backups.

Running the Java Web Application

  1. Starting Tomcat: Run to start Tomcat.
  2. Checking the Status: Verify that Tomcat is running with .
  3. Deploying the Application: Copy your Java web application files to the Tomcat webapps directory.
  4. Reloading Nginx Config: Run to reload the Nginx configuration and start serving the application.

With these steps, you have successfully set up a Java web application using Apache Tomcat 11.0.7 and Nginx on Ubuntu 24.04 LTS. This architecture provides a powerful, high-performance, and secure environment for deploying Java web applications. Enjoy building your next project!

In addition to this setup, one might consider enhancing their home-and-garden lifestyle by installing smart home devices, such as temperature controllers or voice assistants, to manage various aspects of their living environment. On the other hand, for those interested in data-and-cloud-computing, the high-performance environment established here can be leveraged to build and deploy advanced web applications that process and analyze vast amounts of data, thereby driving technology innovation.

Read also:

    Latest