{"id":16342,"date":"2024-10-31T19:23:51","date_gmt":"2024-10-31T19:23:51","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16342"},"modified":"2024-11-01T21:03:36","modified_gmt":"2024-11-01T21:03:36","password":"","slug":"how-to-install-and-configure-apache-tomcat-on-linux","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/","title":{"rendered":"How to Install and Configure Apache Tomcat on Linux &#8211; Ubuntu"},"content":{"rendered":"\n<p>Apache Tomcat is an open-source implementation of Java Servlets, JavaServer Pages (JSP), and Java Expression Language. It\u2019s widely used for running web applications that require Java. Here\u2019s a step-by-step guide to installing and configuring Apache Tomcat on a Linux server, with a focus on Ubuntu and other Debian-based systems.<\/p>\n\n\n\n<p><strong>1. Installing Java<\/strong><\/p>\n\n\n\n<p>Apache Tomcat requires Java to run. If you don\u2019t already have Java installed, use the OpenJDK package, the default Java package on Ubuntu.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Update the system repositories<\/h4>\n\n\n\n<p>Start by updating your repositories to ensure you have access to the latest packages:sudo apt update<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Java<\/h4>\n\n\n\n<p>To install the default Java Development Kit (JDK), run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install default-jdk<\/code><\/pre>\n\n\n\n<p>After the installation, verify it by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<p><strong>2. Setting Up a Tomcat User<\/strong><\/p>\n\n\n\n<p>It\u2019s not recommended to run Tomcat as the root user. Instead, create a dedicated user for Tomcat with restricted privileges:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo useradd -r -m -U -d \/opt\/tomcat -s \/bin\/false tomcat<\/code><\/pre>\n\n\n\n<p>This creates a system user and group named <code>tomcat<\/code> with the home directory set to <code>\/opt\/tomcat<\/code>.<\/p>\n\n\n\n<p><strong>3. Downloading Apache Tomcat<\/strong><\/p>\n\n\n\n<p>Download the latest Tomcat package (version 9.0.34 in this case) from the official website using <code>wget<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -c https:\/\/downloads.apache.org\/tomcat\/tomcat-9\/v9.0.34\/bin\/apache-tomcat-9.0.34.tar.gz<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Extract the Tomcat Archive<\/h4>\n\n\n\n<p>After downloading, extract the package to <code>\/opt\/tomcat<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tar xf apache-tomcat-9.0.34.tar.gz -C \/opt\/tomcat<\/code><\/pre>\n\n\n\n<p>To make future updates easier, create a symbolic link named <code>updated<\/code> that points to the Tomcat installation directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ln -s \/opt\/tomcat\/apache-tomcat-9.0.34 \/opt\/tomcat\/updated<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Update Permissions<\/h4>\n\n\n\n<p>Change ownership of the Tomcat directory so that the <code>tomcat<\/code> user has the necessary permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R tomcat: \/opt\/tomcat\/*\n\nsudo sh -c 'chmod +x \/opt\/tomcat\/updated\/bin\/*.sh'<\/code><\/pre>\n\n\n\n<p><strong>4. Configuring Tomcat as a Service<\/strong><\/p>\n\n\n\n<p>To run Tomcat as a systemd service, create a systemd unit file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create a Unit File<\/h4>\n\n\n\n<p>Use your preferred text editor to create the service file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/systemd\/system\/tomcat.service<\/code><\/pre>\n\n\n\n<p>Add the following configuration. Replace <code>JAVA_HOME<\/code> with your Java installation path if it\u2019s different:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Apache Tomcat Web Application Container\nAfter=network.target\n\n&#91;Service]\nType=forking\n\nEnvironment=\"JAVA_HOME=\/usr\/lib\/jvm\/java-1.11.0-openjdk-amd64\"\nEnvironment=\"CATALINA_PID=\/opt\/tomcat\/updated\/temp\/tomcat.pid\"\nEnvironment=\"CATALINA_HOME=\/opt\/tomcat\/updated\/\"\nEnvironment=\"CATALINA_BASE=\/opt\/tomcat\/updated\/\"\nEnvironment=\"CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC\"\nEnvironment=\"JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:\/dev\/.\/urandom\"\n\nExecStart=\/opt\/tomcat\/updated\/bin\/startup.sh\nExecStop=\/opt\/tomcat\/updated\/bin\/shutdown.sh\n\nUser=tomcat\nGroup=tomcat\nUMask=0007\nRestartSec=10\nRestart=always\n\n&#91;Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Reload the Systemd Daemon<\/h4>\n\n\n\n<p>After creating the unit file, reload the systemd daemon to recognize the new service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl daemon-reload<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Start the Tomcat Service<\/h4>\n\n\n\n<p>Now, start the Tomcat service with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start tomcat<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Verify Tomcat Status<\/h4>\n\n\n\n<p>Check the status of the Tomcat service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status tomcat<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Enable Tomcat on Startup<\/h4>\n\n\n\n<p>To ensure Tomcat starts on system boot, enable the service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable tomcat<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>5. Configuring the Firewall<\/strong><\/h5>\n\n\n\n<p>If your system has a firewall enabled, you need to allow access to port 8080, the default port for Tomcat.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow 8080\/tcp<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>6. Verifying the Installation<\/strong><\/h5>\n\n\n\n<p>Open a web browser and enter the following URL, replacing <code>&lt;YourIPAddress><\/code> with your server\u2019s IP address:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;your_ip_address:8080<\/code><\/pre>\n\n\n\n<p>If the installation was successful, you should see the Tomcat default welcome page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Author&#8217;s Final Word<\/h2>\n\n\n\n<p>This setup provides a solid foundation for running Apache Tomcat on a Linux server. You can now deploy web applications that rely on Java Servlets, JSPs, and other Java-based technologies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Tomcat is an open-source implementation of Java Servlets, JavaServer Pages (JSP), and Java Expression Language. It\u2019s widely used for running web applications that require Java. Here\u2019s a step-by-step guide to installing and configuring Apache Tomcat on a Linux server, with a focus on Ubuntu and other Debian-based systems. 1. Installing Java Apache Tomcat requires [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16342","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-06","word_count":603,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Install and Configure Apache Tomcat on Linux - Ubuntu -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install and Configure Apache Tomcat on Linux - Ubuntu -\" \/>\n<meta property=\"og:description\" content=\"Apache Tomcat is an open-source implementation of Java Servlets, JavaServer Pages (JSP), and Java Expression Language. It\u2019s widely used for running web applications that require Java. Here\u2019s a step-by-step guide to installing and configuring Apache Tomcat on a Linux server, with a focus on Ubuntu and other Debian-based systems. 1. Installing Java Apache Tomcat requires [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T21:03:36+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-apache-tomcat-on-linux\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-apache-tomcat-on-linux\\\/\",\"name\":\"How to Install and Configure Apache Tomcat on Linux - Ubuntu -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-10-31T19:23:51+00:00\",\"dateModified\":\"2024-11-01T21:03:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-apache-tomcat-on-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-apache-tomcat-on-linux\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-install-and-configure-apache-tomcat-on-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install and Configure Apache Tomcat on Linux &#8211; Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install and Configure Apache Tomcat on Linux - Ubuntu -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to Install and Configure Apache Tomcat on Linux - Ubuntu -","og_description":"Apache Tomcat is an open-source implementation of Java Servlets, JavaServer Pages (JSP), and Java Expression Language. It\u2019s widely used for running web applications that require Java. Here\u2019s a step-by-step guide to installing and configuring Apache Tomcat on a Linux server, with a focus on Ubuntu and other Debian-based systems. 1. Installing Java Apache Tomcat requires [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/","article_modified_time":"2024-11-01T21:03:36+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/","name":"How to Install and Configure Apache Tomcat on Linux - Ubuntu -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-10-31T19:23:51+00:00","dateModified":"2024-11-01T21:03:36+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-install-and-configure-apache-tomcat-on-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Install and Configure Apache Tomcat on Linux &#8211; Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16342"}],"version-history":[{"count":2,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16342\/revisions"}],"predecessor-version":[{"id":16529,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16342\/revisions\/16529"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16342"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16342"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}