{"id":2001,"date":"2017-02-07T23:40:42","date_gmt":"2017-02-07T23:40:42","guid":{"rendered":"http:\/\/blog.paranoidprofessor.com\/?p=2001"},"modified":"2017-02-07T23:40:42","modified_gmt":"2017-02-07T23:40:42","slug":"installing-tomcat-on-linux","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2017\/02\/07\/installing-tomcat-on-linux\/","title":{"rendered":"Installing Tomcat on Linux"},"content":{"rendered":"<p>Most of my needs for serving up web content can normally be summed up in a few static pages. \u00a0To serve those pages up you would usually find an Apache server in the background. \u00a0Apache is a general purpose server which serves static html data.<\/p>\n<p>Tomcat on the other hand is a JSP server for serving up dynamic data. \u00a0Tomcat is a server that can interpret the\u00a0commands it is given. \u00a0The server ends up running the java code and providing the output to the caller.<\/p>\n<p>I wanted to test out restful web services but in order to do that I needed to get Tomcat up and running. The steps are pretty straight forward.<\/p>\n<ul>\n<li>create a Tomcat user and\u00a0group<\/li>\n<li><a href=\"http:\/\/tomcat.apache.org\/download-80.cgi#8.5.11\">download Tomcat<\/a><\/li>\n<li>unpack<\/li>\n<li>move it to install directory<\/li>\n<li>setup directory permissions<\/li>\n<li>create systemd control file<\/li>\n<li>reload systemd daemon<\/li>\n<li>restart tomcat<\/li>\n<li>test Tomcat server<\/li>\n<\/ul>\n<p>I simply followed the tutorial and within a few minutes had a working system.<\/p>\n<p><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-apache-tomcat-8-on-ubuntu-16-04\">https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-apache-tomcat-8-on-ubuntu-16-04<\/a><\/p>\n<p>One interesting side note is that this tutorial also described how to setup a systemd process.<\/p>\n<p>The command for starting, stopping or checking the tomcat server are quite similar.\u00a0 They are not difficult commands but despite that fact I quickly put together three scripts so I don&#8217;t need to remember the details.<\/p>\n<p>start-tomcat.sh<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo systemctl start tomcat\r\n<\/pre>\n<p>stop-tomcat.sh<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo systemctl stop tomcat\r\n<\/pre>\n<p>status-tomcat.sh<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo systemctl status tomcat\r\n<\/pre>\n<h2>Afterword<\/h2>\n<p>I had a few small difficulties with\u00a0tomcat once it was installed. The problems were not Tomcat itself but rather using some of the scripts that ship with tomcat. \u00a0The script that I was specifically having problems with was version.sh which is located in the \/opt\/tomcat\/bin directory.<\/p>\n<p>In addition to the setup described in the tutorial I also did the following<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd \/opt\/tomcat\r\nchmod 755 bin\r\ncd \/opt\/tomcat\/bin\r\nchmod 755 *sh\r\nchmod 754 *jar\r\n<\/pre>\n<p>This was only the start. I tried running the version.sh script and ended up seeing the following error.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n.\/version.sh\r\nUsing CATALINA_BASE:\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\r\nUsing CATALINA_HOME:\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\r\nUsing CATALINA_TMPDIR: \/opt\/apache-tomcat-8.5.11\/temp\r\nUsing JRE_HOME:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/usr\r\nUsing CLASSPATH:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\/bin\/bootstrap.jar:\/opt\/apache-tomcat-8.5.11\/bin\/tomcat-juli.jar\r\nError: Could not find or load main class org.apache.catalina.util.ServerInfo\r\n<\/pre>\n<p>This last little issue was due to the jar files not being readable by a non-tomcat user (ie world file permissions)<\/p>\n<p>Once I changed the permissions to 644 it was then possible to run the version script<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nUsing CATALINA_BASE:\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\r\nUsing CATALINA_HOME:\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\r\nUsing CATALINA_TMPDIR: \/opt\/apache-tomcat-8.5.11\/temp\r\nUsing JRE_HOME:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/usr\r\nUsing CLASSPATH:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/opt\/apache-tomcat-8.5.11\/bin\/bootstrap.jar:\/opt\/apache-tomcat-8.5.11\/bin\/tomcat-juli.jar\r\nServer version: Apache Tomcat\/8.5.11\r\nServer built:\u00a0\u00a0 Jan 10 2017 21:02:52 UTC\r\nServer number:\u00a0 8.5.11.0\r\nOS Name:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Linux\r\nOS Version:\u00a0\u00a0\u00a0\u00a0 4.4.0-53-generic\r\nArchitecture:\u00a0\u00a0 i386\r\nJVM Version:\u00a0\u00a0\u00a0 1.8.0_121-b13\r\nJVM Vendor:\u00a0\u00a0\u00a0\u00a0 Oracle Corporation\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Most of my needs for serving up web content can normally be summed up in a few static pages. \u00a0To serve those pages up you would usually find an Apache server in the background. \u00a0Apache is a general purpose server &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2017\/02\/07\/installing-tomcat-on-linux\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2001"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=2001"}],"version-history":[{"count":8,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2001\/revisions"}],"predecessor-version":[{"id":2074,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/2001\/revisions\/2074"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=2001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=2001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=2001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}