In this tutorial, we are going to install Tomcat 10 and secure it with an SSL certificate on AlmaLinux OS.
Tomcat is an open-source application written in Java program language used for rendering Java web pages and executing Java servlets. Tomcat is also known as Apache Tomcat and it can be installed on many Linux distributions such as Debian, Ubuntu, CentOS, and of course AlmaLinux. In this tutorial, we are going to install Tomcat 10 and set up a reverse proxy with Apache configuration so we can secure the domain with an SSL certificate.
Installing Tomcat 10 on AlmaLinux with Apache as a reverse proxy can take up to 15 minutes. Let’s get started!
Table of Contents
Prerequisites
- A server with AlmaLinux as OS
- A valid domain pointed to the server IP address
- User privileges: root or non-root user with sudo privileges
Step 1. Update the System
After a fresh installation of AlmaLinux, we need to update the packages to the latest versions available:
Step 2. Install Apache2 Web Server
To install the Apache2 execute the following command:
To start and enable the apache service, execute the commands below:
Check the status of the Apache service:
You should receive the following output:
Step 3. Install Java
To install the latest Java 17 version along with other dependencies execute the following commands:
After successfull installation check the installed version.
You should receive the following output:
Step 4. Install Tomcat 10
First, we need to create a directory for tomcat installation, a tomcat user, and a group.
Download Tomcat 10 and extract it in the /opt/tomcat directory on your server.
Once, downloaded and extracted, set the right permissions.
Next, is to create a Systemd Service File for Tomcat.
Open the file, and paste the following lines of code.
Save, the file close it and restart the daemon.
Start and enable the Tomcat service:
Once started check the status of the service:
You should receive the following output:
Step 5. Create Apache as a reverse proxy for Tomcat
Now, you can access Tomcat on port 8080 at http://YourServerIPAddress:8080, but it will be insecurity and as we know, we can only install an SSL certificate on the domain.
Open the file with your favorite editor and paste the following lines of code:
Save the file, close it and check the Apache syntax.
You should receive the following output:
If the syntax is OK, restart the service
Now, you can access your Tomcat via domain at http://yourdomain.com, but we are not done here in this tutorial. The next step is about securing the Tomcat domain with an SSL certificate.
Step 6. Install SSL certificate
Install first, the mod_ssl extension and python certbot.
Once, this is installed you can generate an SSL certificate with the following command:
After successful installation you should receive the following output:
Now you can access your Tomcat interface securely at https://yourdomain.com
Congratulations! You successfully installed and secured Tomcat 10 with an SSL certificate on AlmaLinux. If you find it difficult to install and configure all these with the provided commands, you can always contact our technical support and they will do the rest for you. We are available 24/7.
P.S If you liked this post on how to install and secure Tomcat on AlmaLinux, please share it with your friends on social networks or simply leave a reply below. Thanks.