{"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-01-13T12:10:20","modified_gmt":"2026-01-13T12:10:20","slug":"how-to-install-tomcat-on-ubuntu","status":"publish","type":"post","link":"\/tutorials\/how-to-install-tomcat-on-ubuntu","title":{"rendered":"How to install Tomcat on Ubuntu"},"content":{"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.<\/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\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/public\" 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=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><\/div><p>\n\n\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=\"\/tutorials\/sudo-and-the-sudoers-file\/\">sudo&nbsp;privileges<\/a> set up on your server. Remember to access your server with <a href=\"\/tutorials\/ssh-tutorial-how-does-ssh-work\">SSH<\/a>. Check out our <a href=\"\/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\">\n<figure data-wp-context='{\"imageId\":\"69e0512929006\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img 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-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/04\/browser-terminal-button-on-hpenel.png\/public\" 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=\"(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-async--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=\"\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" 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=\"(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=\"\/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\" target=\"_blank\" rel=\"noopener\">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=\"\/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=\"\/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=\"\/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>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Check out our other article to learn more about <a href=\"\/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<\/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=\"\/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\">\n<figure data-wp-context='{\"imageId\":\"69e051292be5f\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img 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-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-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=\"(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-async--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\">\n<figure data-wp-context='{\"imageId\":\"69e051292d561\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img 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-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-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=\"(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-async--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\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\"><img decoding=\"async\" width=\"1024\" height=\"465\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2016\/09\/hpanel-vps-firewall-configuration.png\/public\" 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=\"(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>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Managing firewall rules with Kodee<\/h4>\n                    <p>Hostinger VPS hosting users can ask our <a href=\"https:\/\/www.hostinger.com\/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<\/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>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Learn What Else Your Ubuntu Can Do<\/h4>\n                    <p><a href=\"\/tutorials\/how-to-list-installed-packages-on-ubuntu\/\">How to List Packages in Ubuntu<\/a><br>\n<a href=\"\/tutorials\/how-to-install-git-on-ubuntu\">How to Install Git on Ubuntu<\/a><br>\n<a href=\"\/tutorials\/how-to-setup-ftp-server-on-ubuntu-vps\/\">How to Setup an FTP Server for Ubuntu<\/a><br>\n<a href=\"\/tutorials\/how-to-install-node-ubuntu\">How to Install Node.js in Ubuntu<\/a><br>\n<\/p>\n                <\/div>\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 [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-install-tomcat-on-ubuntu\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":0,"comment_status":"closed","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":[22646,22644],"tags":[],"class_list":["post-16321","post","type-post","status-publish","format-standard","hentry","category-pre-installed-applications","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-UK","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\/tutorials\/wp-json\/wp\/v2\/posts\/16321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=16321"}],"version-history":[{"count":23,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/16321\/revisions"}],"predecessor-version":[{"id":139031,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/16321\/revisions\/139031"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=16321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=16321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=16321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}