{"id":2903,"date":"2018-02-17T14:26:59","date_gmt":"2018-02-17T14:26:59","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2903"},"modified":"2018-02-17T14:28:40","modified_gmt":"2018-02-17T14:28:40","slug":"how-to-setup-tomcat-in-linux-mint","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2018\/02\/17\/how-to-setup-tomcat-in-linux-mint\/","title":{"rendered":"How To Setup Tomcat in Linux Mint"},"content":{"rendered":"<p>This pertains to Linux Mint 18 . Most likely it will work for slightly older versions as well. It is assumed that Java has already been installed on the system and is either Java 8 or 9 or later.<\/p>\n<p>1.Create a user group<\/p>\n<pre>sudo groupadd tomcat<\/pre>\n<p>2.Add a user to the above group and set the user home to the folder where tomcat will be installed. Prevent this user from having a shell to log in to.<\/p>\n<pre class=\"code-pre command\"><code>sudo useradd -s \/bin\/false -g tomcat -d \/opt\/tomcat tomcat<\/code><\/pre>\n<p>3.Install tomcat from the official downloads page. We are downloading version 9 from https:\/\/tomcat.apache.org\/download-90.cgi . In this page, under Binary Distributions &#8211; Core, download the tar.gz file<\/p>\n<p>4.Change directory to where you have downloaded the tar.gz file eg. cd ~\/Downloads . We are going to create the tomcat folder and then unzip the file contents into that folder.<\/p>\n<pre>sudo mkdir \/opt\/tomcat\r\nsudo tar xzvf apache-tomcat-8*tar.gz -C \/opt\/tomcat --strip-components=1\r\n\r\n\r\n<\/pre>\n<p>5.Give the tomcat group ownership of the tomcat folder tree<\/p>\n<pre class=\"code-pre command\"><code>sudo chgrp -R tomcat \/opt\/tomcat<\/code><\/pre>\n<p>6.Give read access to the conf tree and execute access to the conf folder<\/p>\n<pre class=\"code-pre command\"><code>sudo chmod -R g+r conf<\/code><\/pre>\n<pre class=\"code-pre command\"><code>sudo chmod g+x conf<\/code><\/pre>\n<p>6.Give ownership to the main folders to the tomcat user<\/p>\n<p class=\"code-pre command\"><code>sudo chown -R tomcat webapps\/ work\/ temp\/ logs\/<\/code><\/p>\n<p>7.Find the path to the installation of Java.<\/p>\n<pre>echo $JAVA_HOME<\/pre>\n<p>8.Set tomcat to run as a system service by creating a .service file for it<\/p>\n<pre class=\"code-pre command\"><code>sudo vi \/etc\/systemd\/system\/tomcat.service<\/code><\/pre>\n<p>9.Put in the contents below and set the JAVA_HOME path as required. Remember to keep the \/jre at the end of the path.<\/p>\n<pre class=\"code-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\nEnvironment=JAVA_HOME=\/usr\/lib\/jvm\/java-8-oracle\/jre\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\nUser=tomcat\r\nGroup=tomcat\r\nUMask=0007\r\nRestartSec=10\r\nRestart=always\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>10.After saving the file, reload systemd daemon<\/p>\n<pre class=\"code-pre command\"><code>sudo systemctl daemon-reload<\/code><\/pre>\n<p>11.Start tomcat<\/p>\n<p class=\"code-pre command\"><code>sudo systemctl start tomcat<\/code><\/p>\n<p>12.You can check the status by the following command<\/p>\n<pre class=\"code-pre command\"><code>sudo systemctl status tomcat\r\n<\/code><\/pre>\n<p>13.If you want tomcat to start automatically at boot then put the following command<\/p>\n<pre class=\"code-pre command\"><code>sudo systemctl enable tomcat<\/code><\/pre>\n<p>14.Setup the default admin credentials for the tomcat web interface by editing the tomcat-users.xml file<\/p>\n<pre class=\"code-pre command\"><code>sudo vi \/opt\/tomcat\/conf\/tomcat-users.xml<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>15.Set your root credentials as desired and save the file<\/p>\n<pre class=\"code-pre \"><code>&lt;tomcat-users . . .&gt;\r\n    &lt;user username=\"<span class=\"highlight\">root<\/span>\" password=\"<span class=\"highlight\">master<\/span>\" roles=\"manager-gui,admin-gui\"\/&gt;\r\n&lt;\/tomcat-users&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p class=\"code-pre command\">15.Tomcat should be ready to run now. Type http:\/\/localhost:8080 in your browser. You should see the following screen:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-2909\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28-620x300.png\" alt=\"\" width=\"620\" height=\"300\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28-620x300.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28-300x145.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28-768x372.png 768w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28-940x455.png 940w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/Apache-Tomcat-8.5.28.png 1240w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>16.If you click on any of the buttons like Server Status or Host Manager it will ask you for admin credentials which are the ones you set in tomcat-users.xml file. Once you have logged in it will show something like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-2910\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager-620x300.png\" alt=\"\" width=\"620\" height=\"300\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager-620x300.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager-300x145.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager-768x372.png 768w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager-940x455.png 940w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2018\/02\/manager.png 1240w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>17.You can stop the tomcat service by<\/p>\n<pre>sudo systemctl stop tomcat<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>This pertains to Linux Mint 18 . Most likely it will work for slightly older versions as well. It is assumed that Java has already <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2018\/02\/17\/how-to-setup-tomcat-in-linux-mint\/\" title=\"How To Setup Tomcat in Linux Mint\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2914,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[319],"tags":[],"class_list":["post-2903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2903"}],"version-history":[{"count":7,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2903\/revisions"}],"predecessor-version":[{"id":2912,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2903\/revisions\/2912"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2914"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}