{"id":16321,"date":"2019-03-29T12:33:02","date_gmt":"2019-03-29T12:33:02","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=16321"},"modified":"2026-03-09T19:19:37","modified_gmt":"2026-03-09T19:19:37","slug":"how-to-install-tomcat-on-ubuntu","status":"publish","type":"post","link":"\/ng\/tutorials\/how-to-install-tomcat-on-ubuntu\/","title":{"rendered":"How to install Tomcat on Ubuntu"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Tomcat, often called Apache Tomcat, is one of the most popular applications designed to execute a Java servlet and render web servers with Java page coding.<\/p><p>Tomcat generates JSP files (server-generated webpages similar to PHP and ASP files) into Java code, further compiling to <strong>.class<\/strong> files by the server, and executed by the Java virtual machine. As of today, Tomcat is definitely one of the more useable servlet containers available.<\/p><p>Many developers favor this open-source application by the Apache Software Foundation. In this tutorial, we&rsquo;ll show you how to install Tomcat on Ubuntu and set it up for use on your VPS.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure>\n<\/div><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites\">Prerequisites<\/h2><p>Before you begin with the guide, have a non-root user with&nbsp;<a href=\"\/ng\/tutorials\/sudo-and-the-sudoers-file\/\">sudo&nbsp;privileges<\/a> set up on your server. Remember to access your server with <a href=\"\/ng\/tutorials\/ssh-tutorial-how-does-ssh-work\/\">SSH<\/a>. Check out our <a href=\"\/ng\/tutorials\/how-to-use-putty-ssh\/\">PuTTY tutorial<\/a> if you&rsquo;re having issues. Alternatively, you can access Hostinger&rsquo;s browser-based SSH terminal straight from hPanel:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58e19b23091\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58e19b23091\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"535\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=1024,h=1024,fit=scale-down\" alt=\"The Browser terminal button on hPanel's VPS overview page\" class=\"wp-image-125795\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ng\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-install-tomcat-on-ubuntu\">How to install Tomcat on Ubuntu<\/h2><p>This tutorial will teach you how to install Tomcat 9 on Ubuntu, and how to configure it for use. <\/p><h3 class=\"wp-block-heading\" id=\"h-1-install-java\">1. Install Java<\/h3><p>Before we install Tomcat on Ubuntu, we need to install Java to execute the Java web application code. OpenJDK is the default Java development in Ubuntu. Installing Java is simple and quick. Just follow the below commands:<\/p><pre class=\"wp-block-preformatted\">sudo apt update<\/pre><p>Install the <a href=\"\/ng\/tutorials\/install-java-ubuntu\/\">OpenJDK<\/a> package by running:<\/p><pre class=\"wp-block-preformatted\">sudo apt install default&ndash;jdk<\/pre><p>Now that JDK is installed in your system, you can create the user tomcat by following the next step.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-create-a-tomcat-user\">2. Create a Tomcat user<\/h3><p>For security, you should not use Tomcat without a unique user. This will make the install of Tomcat on Ubuntu easier. Create a new tomcat group that will run the service:<\/p><pre class=\"wp-block-preformatted\">sudo groupadd tomcat<\/pre><p>Now, the next procedure is to create a new tomcat user. Create user members of the Tomcat group with a home directory opt\/tomcat&nbsp;for running the Tomcat service:<\/p><pre class=\"wp-block-preformatted\">sudo useradd -s \/bin\/false -g tomcat -d \/opt\/tomcat tomcat<\/pre><h3 class=\"wp-block-heading\" id=\"h-3-install-tomcat-on-ubuntu\">3. Install Tomcat on Ubuntu<\/h3><p>The best way to install Tomcat 9 on Ubuntu is to download the latest binary release from the <a href=\"https:\/\/tomcat.apache.org\/download-90.cgi\">Tomcat 9 downloads page<\/a> and configure it manually. If the version is not 9.0.60&nbsp;or it&rsquo;s the latest version, then follow the latest stable version. Just copy the link of the core <a href=\"\/ng\/tutorials\/linux-tar-command-with-examples\/\">tar.gz<\/a> file under the Binary Distributions section.<\/p><p>Now, change to the <strong>\/tmp<\/strong> directory on your server to download the items which you won&rsquo;t need after extracting the Tomcat contents:<\/p><pre class=\"wp-block-preformatted\">cd \/tmp<\/pre><p>To download from the copied link (from Tomcat website), use the following <a href=\"\/ng\/tutorials\/curl-command-with-examples-linux\/\">curl command<\/a>:<\/p><pre class=\"wp-block-preformatted\">cucurl -O https:\/\/dlcdn.apache.org\/tomcat\/tomcat-9\/v9.0.63\/bin\/apache-tomcat-9.0.63.tar.gz<\/pre><h3 class=\"wp-block-heading\" id=\"h-4-update-permissions\">4. Update permissions<\/h3><p>Now that you finished the install of Tomcat on Ubuntu, you need to set up the Tomcat user to have full access to the Tomcat installation. This user needs to have access to the directory. Follow the steps below:<\/p><pre class=\"wp-block-preformatted\">sudo mkdir \/opt\/tomcat<\/pre><pre class=\"wp-block-preformatted\">cd \/opt\/tomcat<\/pre><pre class=\"wp-block-preformatted\">sudo tar xzvf \/tmp\/apache-tomcat-9.0.*tar.gz -C \/opt\/tomcat --strip-components=1<\/pre><p>Now, give the Tomcat group ownership over the entire installation directory with the <a href=\"\/ng\/tutorials\/linux-chown-command\/\">chgrp command<\/a>:<\/p><pre class=\"wp-block-preformatted\">sudo chgrp&nbsp;-R tomcat \/opt\/tomcat<\/pre><p>Next, you need to give the Tomcat user&nbsp;access to the conf directory to view its contents and execute access to the directory itself:<\/p><pre class=\"wp-block-preformatted\">sudo chmod -R g+r conf<\/pre><pre class=\"wp-block-preformatted\">sudo chmod g+x conf<\/pre><p>Make the&nbsp;Tomcat&nbsp;user the owner of the&nbsp;web apps,&nbsp;work,&nbsp;temp, and&nbsp;logs&nbsp;directories:<\/p><pre class=\"wp-block-preformatted\">sudo chown -R tomcat webapps\/ work\/ temp\/ logs\/<\/pre><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Suggested Reading                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Check out our other article to learn more about <a href=\"\/ng\/tutorials\/vps\/change-linux-permissions-and-owners\/\">changing permissions and owners in Linux<\/a> using command-line interface.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-5-create-a-systemd-unit-file\">5. Create a systemd unit file<\/h3><p>We will need to create a new unit file to run Tomcat as a service. Open your text editor and create a file name tomcat.service&nbsp;in the <strong>\/etc\/systemd\/system\/<\/strong>:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/etc\/systemd\/system\/tomcat.service<\/pre><p>Next, paste the following configuration:<\/p><pre class=\"wp-block-preformatted\">[Unit]\nDescription=Apache Tomcat Web Application Container\nAfter=network.target\n\n[Service]\nType=forking\n\nEnvironment=JAVA_HOME=\/usr\/lib\/jvm\/java-1.8.0-openjdk-amd64\/jre\nEnvironment=CATALINA_PID=\/opt\/tomcat\/temp\/tomcat.pid\nEnvironment=CATALINA_Home=\/opt\/tomcat\nEnvironment=CATALINA_BASE=\/opt\/tomcat\nEnvironment=&rsquo;CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC&rsquo;\nEnvironment=&rsquo;JAVA_OPTS.awt.headless=true -Djava.security.egd=file:\/dev\/v\/urandom&rsquo;\n\nExecStart=\/opt\/tomcat\/bin\/startup.sh\nExecStop=\/opt\/tomcat\/bin\/shutdown.sh\n\nUser=tomcat\nGroup=tomcat\nUMask=0007\nRestartSec=10\nRestart=always\n\n[Install]\n\nWantedBy=multi-user.target<\/pre><p>Save and close the file after finishing the given commands above.<\/p><p>Next, Notify the system that you have created a new file by issuing the following command in the command line:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl daemon-reload<\/pre><p>The following commands will allow you to execute the Tomcat service:<\/p><pre class=\"wp-block-preformatted\">cd \/opt\/tomcat\/bin<\/pre><pre class=\"wp-block-preformatted\">sudo .\/startup.sh run<\/pre><h3 class=\"wp-block-heading\" id=\"h-6-adjust-the-firewall\">6. Adjust the firewall<\/h3><p>It is essential to adjust the firewall so the requests get to the service. Tomcat uses port&nbsp;8080&nbsp;to accept conventional requests. Allow traffic to that port by using <a href=\"\/ng\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\/\">UFW<\/a>:<\/p><pre class=\"wp-block-preformatted\">sudo ufw allow 8080<\/pre><p>You can also set up a firewall via hPanel. Select your VPS and navigate to the <strong>Firewall<\/strong> section:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58e19b2776b\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58e19b2776b\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"972\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-firewall-sidebar.png\/public\" alt=\"The Firewall menu on hPanel's VPS dashboard sidebar\" class=\"wp-image-125832\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-firewall-sidebar.png\/w=482,fit=scale-down 482w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-firewall-sidebar.png\/w=149,fit=scale-down 149w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-firewall-sidebar.png\/w=74,fit=scale-down 74w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Then create a new firewall configuration and give it a name. Once created, click the <strong>Edit<\/strong> button:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58e19b29a68\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58e19b29a68\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"402\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/public\" alt=\"The Edit button on hPanel's firewall configuration page\" class=\"wp-image-125841\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/the-firewall-edit-button-on-hpanel.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Lastly, add any preferred configuration and click <strong>Add rule<\/strong>:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"465\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/w=1024,h=1024,fit=scale-down\" alt=\"The process of creating a new firewall rules on hPanel\" class=\"wp-image-90699\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Follow the command below to access the splash page by going to your domain or IP address followed by :8080 in a web browser &ndash; http:\/\/IP:8080<\/p><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Managing firewall rules with Kodee                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Hostinger VPS hosting users can ask our <a href=\"\/blog\/kodee\/\">AI assistant, Kodee<\/a>, to create and activate a new firewall rule on their server. To do so, simply ask it, \"Set a new firewall rule on my VPS that allows connection to port 8080 TCP\/UDP from any IP address.\"<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-7-configure-the-tomcat-web-management-interface\">7. Configure the Tomcat web management interface<\/h3><p>Follow the command below to add a login to your Tomcat user and edit the&nbsp;<strong>tomcat-users.xml<\/strong>&nbsp;file:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/opt\/tomcat\/conf\/tomcat-users.xml<\/pre><p>Now, define the user who can access the files and add username and passwords:<\/p><pre class=\"wp-block-preformatted\">tomcat-users.xml &mdash; Admin User\n&lt;tomcat-users . . .&gt;\n&lt;tomcat-users . . .&gt;\n&lt;user username=\"admin\" password=\"password\" roles=\"manager-gui,admin-gui\"\/&gt;\n&lt;\/tomcat-users&gt;<\/pre><p>For the Manager app, type:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/opt\/tomcat\/webapps\/manager\/META-INF\/context.xml<\/pre><p>For the Host Manager app, type:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/opt\/tomcat\/webapps\/host-manager\/META-INF\/context.xml<\/pre><p>To restart the Tomcat service and view the effects:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl restart tomcat<\/pre><h3 class=\"wp-block-heading\" id=\"h-8-access-the-online-interface\">8. Access the online interface<\/h3><p>Now that you already have a user, you can access the web management interface in a browser. Once again, you can access the interface by providing your server&rsquo;s domain name or IP address followed by port 8080 in your browser &ndash; http:\/\/server_domain_or_IP:8080<\/p><p>Let&rsquo;s take a look at the Manager App, accessible via the link &ndash; http:\/\/server_domain_or_IP:8080\/manager\/html.<\/p><p>Make sure that you entered the account credentials to the <strong>t<\/strong><strong>omcat-users.xml<\/strong>&nbsp;file.<\/p><p>We use the <strong>Web Application Manager<\/strong> to manage our Java applications. You can Begin, Stop, Reload, Deploy, and Undeploy all apps here.&nbsp;Lastly, it provides data about your server at the bottom of the page.<\/p><p>Now let&rsquo;s look at the<strong> Host Manager<\/strong>, accessible via http:\/\/server_domain_or_IP:8080\/host-manager\/html\/<\/p><p>From the <strong>Virtual Host Manager<\/strong> page, you can also add new virtual hosts that follow your application form&rsquo;s guidelines.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Ubuntu supports Tomcat 6 and the latest version Tomcat 9 which includes new features to allow users to work freely on the application.<\/p><p>With this tutorial, your Tomcat installation is functional but entirely unencrypted, so other parties on a web browser can view or change the information or data, passwords, and other sensitive data. The only way to resolve this issue is to encrypt your connections with SSL.<\/p><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Learn What Else Your Ubuntu Can Do                <\/p>\n            <\/div>\n            <p class=\"protip__content\"><a href=\"\/ng\/tutorials\/how-to-list-installed-packages-on-ubuntu\/\">How to List Packages in Ubuntu<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-install-git-on-ubuntu\/\">How to Install Git on Ubuntu<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-setup-ftp-server-on-ubuntu-vps\/\">How to Setup an FTP Server for Ubuntu<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-install-node-ubuntu\/\">How to Install Node.js in Ubuntu<\/a><br>\n<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-install-tomcat-on-ubuntu-faq\">Install Tomcat on Ubuntu FAQ<\/h2><p>In this section, we&rsquo;ll cover some of the most common questions about configuring Tomcat on Ubuntu.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1708600355455\"><h3 class=\"schema-faq-question\">What Command Do I Use to Install Tomcat on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">To install Tomcat on Ubuntu, use <strong>sudo apt install tomcat9<\/strong> for Tomcat version 9. Adjust the version number based on your requirements.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1708600298448\"><h3 class=\"schema-faq-question\">Can I Install Multiple Versions of Tomcat on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">Yes, you can install multiple Tomcat versions on Ubuntu. Ensure they are configured to run on different ports to avoid conflicts.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1708600385121\"><h3 class=\"schema-faq-question\">What Is the Default Installation Directory for Tomcat on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">The default installation directory for Tomcat on Ubuntu is <strong>\/var\/lib\/tomcat9<\/strong> for Tomcat 9. This path varies with the version.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Tomcat, often called Apache Tomcat, is one of the most popular applications designed to execute a Java servlet and render web servers with Java page coding. Tomcat generates JSP files (server-generated webpages similar to PHP and ASP files) into Java code, further compiling to .class files by the server, and executed by the Java virtual [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/how-to-install-tomcat-on-ubuntu\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Install Tomcat on Ubuntu","rank_math_description":"Tomcat is a great way to improve your VPS project. Learn how to install Tomcat on Ubuntu. Follow along and get started!","rank_math_focus_keyword":"install tomcat ubuntu","footnotes":""},"categories":[22644],"tags":[],"class_list":["post-16321","post","type-post","status-publish","format-standard","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-installer-tomcat-sur-ubuntu","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-instalar-tomcat-en-ubuntu","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/install-tomcat-ubuntu","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-tomcat-on-ubuntu\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-tomcat-on-ubuntu\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-instalar-tomcat-en-ubuntu","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-instalar-tomcat-en-ubuntu","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-instalar-tomcat-en-ubuntu","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-tomcat-on-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=16321"}],"version-history":[{"count":24,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16321\/revisions"}],"predecessor-version":[{"id":145073,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/16321\/revisions\/145073"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=16321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=16321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=16321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}