Install Apache Tomcat

How to Install Apache Tomcat 10 on Ubuntu 22.04 with Nginx

Posted on

Set up Apache Tomcat 10 on Ubuntu 22.04 with Nginx. Apache Tomcat is an open supply net server and a servlet container which is especially used to server Java primarily based purposes.

On this information you’ll learn to set up Apache Tomcat 10 on Ubuntu 22.04 and safe the setup with Nginx and Let’s Encrypt SSL.


  • A server with Ubuntu 22.04 OS
  • A person with sudo privileges.

Preliminary Setup

Begin by updating the server packages to the most recent model obtainable.

sudo apt replace
sudo apt dist-upgrade -y

Create New Person for Tomcat

It will be higher if Tomcat runs because it’s personal unprivileged person. Execute the next command to create a brand new person with required privileges for Tomcat. This person wont be allowed to be logged in to SSH.

sudo useradd -m -d /decide/tomcat -U -s /bin/false tomcat

Set up Java

Set up default JDK utilizing the beneath command. Examine right here for extra detailed guide to install Java.

sudo apt set up default-jdk

As soon as the set up is accomplished, test the model utilizing the next command.

java -version

Your output needs to be much like the one beneath.

openjdk model "11.0.15" 2022-04-19
OpenJDK Runtime Atmosphere (construct 11.0.15+10-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (construct 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, combined mode, sharing)

Set up Apache Tomcat

Obtain the most recent model of Tomcat from their official downloads page. Select the tar.gz below the core part.

Obtain the archive utilizing wget.

cd ~/

Extract the contents to /decide/tomcat listing.

sudo tar xzvf apache-tomcat-10*tar.gz -C /decide/tomcat --strip-components=1

Configure appropriate permissions for Tomcat information.

sudo chown -R tomcat:tomcat /decide/tomcat/
sudo chmod -R u+x /decide/tomcat/bin

Configure Admin Customers

Now we have to setup customers who can entry the Host supervisor and the Supervisor pages in Tomcat.

Add the customers with passwords in /decide/tomcat/conf/tomcat-users.xml

sudo nano /decide/tomcat/conf/tomcat-users.xml

Add the next strains earlier than the tip tag.

<function rolename="manager-gui" />
<person username="supervisor" password="secure_password" roles="manager-gui" />

<function rolename="admin-gui" />
<person username="admin" password="secure_password" roles="manager-gui,admin-gui" />

Now now we have 2 customers who can entry the Supervisor and the Host supervisor pages.

Configure Tomcat as a Service

Right here we’ll configure a systemd service to handle Tomcat to start out, cease and restart mechanically.

Notice the Java location.

sudo update-java-alternatives -l
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64

Create a systemd file.

sudo nano /and so forth/systemd/system/tomcat.service

Add the next contents to the file.




Atmosphere="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"


Restart=all the time


Change JAVA_HOME variable with the one you famous earlier than.

Reload systemd daemon for the adjustments to take impact.

sudo systemctl daemon-reload

Begin Tomcat.

sudo systemctl begin tomcat

Allow Tomcat to start out at system boot.

sudo systemctl allow tomcat

Examine Tomcat standing.

sudo systemctl standing tomcat
● tomcat.service - Tomcat
     Loaded: loaded (/and so forth/systemd/system/tomcat.service; disabled; vendor preset: enabled)
     Energetic: lively (working) since Wed 2022-05-25 06:41:36 UTC; 6s in the past
    Course of: 5155 ExecStart=/decide/tomcat/bin/ (code=exited, standing=0/SUCCESS)
   Essential PID: 5302 (java)
      Duties: 29 (restrict: 1151)
     Reminiscence: 132.7M
     CGroup: /system.slice/tomcat.service

Set up Nginx

Set up Nginx utilizing the next command.

sudo apt set up nginx

Take away default configurations

sudo rm /and so forth/nginx/sites-available/default
sudo rm /and so forth/nginx/sites-enabled/default

Configure Nginx Proxy for Tomcat

Create new Nginx configuration

sudo nano /and so forth/nginx/sites-available/yourdomainname.conf

Paste the next

server {
     pay attention [::]:80;
     pay attention 80;


     location / {
         proxy_pass http://localhost:8080;
         proxy_http_version 1.1;
         proxy_set_header Improve $http_upgrade;
         proxy_set_header Connection 'improve';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;

Save and exit the file.

Allow your configuration by making a symbolic hyperlink.

sudo ln -s /and so forth/nginx/sites-available/yourdomainname.conf /and so forth/nginx/sites-enabled/yourdomainname.conf

Set up Let’s Encrypt SSL with Certbot

Set up Certbot package deal.

sudo apt set up python3-certbot-nginx

Set up SSL certificates utilizing the beneath command.

sudo certbot --nginx --redirect --no-eff-email --agree-tos -m [email protected] -d -d

In case your area is pointed to the server the free SSL certificates will get put in and HTTP to HTTPS redirection will get configured mechanically and Nginx will get restarted by itself for the adjustments to take impact.

If you wish to restart you may test your Nginx configuration and restart it.

sudo nginx -t
sudo service nginx restart

Put together your self for a task working as an Information Technology Professional with Linux working system

Confirm Tomcat Set up

Now test your area in your browser.

Install Apache Tomcat

Click on Supervisor App, you may be prompted to enter username and password. Use the one now we have configured within the Tomcat customers part.

Manager App

You may also have a look on the Host Supervisor web page.

Host Manager

You may also view the server standing.


Now you will have discovered how one can set up Apache Tomcat on Ubuntu 22.04 and safe with Nginx and Let’s Encrypt SSL..

Thanks on your time. Should you face any drawback or any suggestions, please depart a remark beneath.

offshore vps