{"id":2601,"date":"2025-11-04T15:29:27","date_gmt":"2023-03-09T03:23:59","guid":{"rendered":""},"modified":"2025-02-02T00:46:18","modified_gmt":"2025-02-01T23:46:18","slug":"how-to-install-and-configure-apache-tomcat-9-on-ubuntu-20-04-lts","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-and-configure-apache-tomcat-9-on-ubuntu-20-04-lts\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 and Configure Apache Tomcat 9 on Ubuntu 20.04 LTS"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<h1>\u00a0<\/h1>\n<p>Apache Tomcat is a popular open-source web server and servlet container used to serve Java applications. In this guide, we will walk you through how to install and configure Apache Tomcat 9 on Ubuntu 20.04 LTS. Whether you&#8217;re hosting Java applications on a  or any other server, Tomcat provides a robust and scalable platform for web applications.<\/p>\n<h2>Prerequisites<\/h2>\n<p>Before you begin, ensure you have the following:<\/p>\n<ul>\n<li>An Ubuntu 20.04 LTS server, which can be hosted on a <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">UK Windows VPS<\/a>, <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPSVirtual Private Servers<\/a>, or another <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPS Hosting UK<\/a> solution.<\/li>\n<li>Root or sudo privileges on your server.<\/li>\n<\/ul>\n<h2>Step 1: Update Your System<\/h2>\n<p>Before installing any software, update your system to ensure all packages are up to date:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n<h2>Step 2: Install Java<\/h2>\n<p>Apache Tomcat requires Java to run. Install OpenJDK, the open-source version of Java, by running the following command:<\/p>\n<pre><code>sudo apt install default-jdk -y<\/code><\/pre>\n<p>Verify the installation by checking the Java version:<\/p>\n<pre><code>java -version<\/code><\/pre>\n<h2>Step 3: Create a Tomcat User<\/h2>\n<p>For security reasons, it is recommended to run Tomcat under a non-root user. Create a new Tomcat user and group:<\/p>\n<pre><code>sudo groupadd tomcat\r\nsudo useradd -m -g tomcat -s \/bin\/bash tomcat<\/code><\/pre>\n<h2>Step 4: Install Apache Tomcat 9<\/h2>\n<p>Download the latest version of Apache Tomcat 9 from the official Apache Tomcat website. You can use the following <code>wget<\/code> command to download the Tomcat archive:<\/p>\n<pre><code>cd \/tmp\r\nwget https:\/\/downloads.apache.org\/tomcat\/tomcat-9\/v9.0.62\/bin\/apache-tomcat-9.0.62.tar.gz<\/code><\/pre>\n<p>Extract the archive to the <code>\/opt<\/code> directory:<\/p>\n<pre><code>sudo tar -xvf apache-tomcat-9.0.62.tar.gz -C \/opt<\/code><\/pre>\n<p>Rename the extracted directory for convenience:<\/p>\n<pre><code>sudo mv \/opt\/apache-tomcat-9.0.62 \/opt\/tomcat<\/code><\/pre>\n<h2>Step 5: Set Permissions for Tomcat<\/h2>\n<p>Set the correct permissions for the Tomcat directories:<\/p>\n<pre><code>sudo chown -R tomcat:tomcat \/opt\/tomcat\r\nsudo chmod -R 755 \/opt\/tomcat<\/code><\/pre>\n<h2>Step 6: Configure Tomcat as a Systemd Service<\/h2>\n<p>To run Tomcat as a service, create a new systemd service file:<\/p>\n<pre><code>sudo nano \/etc\/systemd\/system\/tomcat.service<\/code><\/pre>\n<p>Add the following configuration to the file:<\/p>\n<pre><code>[Unit]\r\nDescription=Apache Tomcat Web Application Container\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\n\r\nUser=tomcat\r\nGroup=tomcat\r\n\r\nEnvironment=\"JAVA_HOME=\/usr\/lib\/jvm\/java-11-openjdk-amd64\"\r\nEnvironment=\"CATALINA_PID=\/opt\/tomcat\/temp\/tomcat.pid\"\r\nEnvironment=\"CATALINA_HOME=\/opt\/tomcat\"\r\nEnvironment=\"CATALINA_BASE=\/opt\/tomcat\"\r\nEnvironment=\"CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC\"\r\nEnvironment=\"JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:\/dev\/.\/urandom\"\r\n\r\nExecStart=\/opt\/tomcat\/bin\/startup.sh\r\nExecStop=\/opt\/tomcat\/bin\/shutdown.sh\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/code><\/pre>\n<p>Reload the systemd daemon to apply the changes:<\/p>\n<pre><code>sudo systemctl daemon-reload<\/code><\/pre>\n<p>Start the Tomcat service and enable it to start on boot:<\/p>\n<pre><code>sudo systemctl start tomcat\r\nsudo systemctl enable tomcat<\/code><\/pre>\n<h2>Step 7: Configure Firewall (Optional)<\/h2>\n<p>If you have a firewall running on your server, allow traffic on port 8080, which Tomcat uses by default:<\/p>\n<pre><code>sudo ufw allow 8080\/tcp<\/code><\/pre>\n<h2>Step 8: Access the Tomcat Web Interface<\/h2>\n<p>Tomcat should now be running. Open your web browser and navigate to <code>http:\/\/your-server-ip:8080<\/code>. You should see the Apache Tomcat welcome page.<\/p>\n<h2>Step 9: Secure Tomcat with Let&#8217;s Encrypt SSL (Optional)<\/h2>\n<p>If you want to secure your Tomcat instance using SSL, you can configure Let&#8217;s Encrypt. First, install Certbot:<\/p>\n<pre><code>sudo apt install certbot -y<\/code><\/pre>\n<p>Obtain an SSL certificate using Certbot:<\/p>\n<pre><code>sudo certbot certonly --standalone -d your-domain.com -d www.your-domain.com<\/code><\/pre>\n<p>After obtaining the certificate, configure Tomcat to use SSL by editing the <code>server.xml<\/code> file in the <code>\/opt\/tomcat\/conf<\/code> directory. Add or modify the following section:<\/p>\n<pre><code>&lt;Connector port=\"8443\" protocol=\"org.apache.coyote.http11.Http11NioProtocol\"\r\n               maxThreads=\"150\" SSLEnabled=\"true\"&gt;\r\n        &lt;SSLHostConfig&gt;\r\n            &lt;Certificate certificateFile=\"\/etc\/letsencrypt\/live\/your-domain.com\/fullchain.pem\"\r\n                         certificateKeyFile=\"\/etc\/letsencrypt\/live\/your-domain.com\/privkey.pem\"\r\n                         type=\"RSA\" \/&gt;\r\n        &lt;\/SSLHostConfig&gt;\r\n    &lt;\/Connector&gt;<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>By following these steps, you have successfully installed and configured Apache Tomcat 9 on Ubuntu 20.04 LTS. Whether you\u2019re hosting Java applications on a , <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Microsoft SQL VPS Windows<\/a>, or another <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPS<\/a>, Apache Tomcat provides a powerful and flexible platform for running web applications.<\/p>\n<footer>\n<p>For more VPS hosting options, visit . They offer a variety of <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPSVirtual Private Servers<\/a> and <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">Windows VPS Hosting UK<\/a> solutions tailored to your needs.<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 Apache Tomcat is a popular open-source web server and servlet container used to serve Java applications. In this guide, we will walk you through how to\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-2601","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=2601"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2601\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=2601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=2601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=2601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}