Installing Tomcat on Linux

Most of my needs for serving up web content can normally be summed up in a few static pages.  To serve those pages up you would usually find an Apache server in the background.  Apache is a general purpose server which serves static html data.

Tomcat on the other hand is a JSP server for serving up dynamic data.  Tomcat is a server that can interpret the commands it is given.  The server ends up running the java code and providing the output to the caller.

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.

  • create a Tomcat user and group
  • download Tomcat
  • unpack
  • move it to install directory
  • setup directory permissions
  • create systemd control file
  • reload systemd daemon
  • restart tomcat
  • test Tomcat server

I simply followed the tutorial and within a few minutes had a working system.

One interesting side note is that this tutorial also described how to setup a systemd process.

The command for starting, stopping or checking the tomcat server are quite similar.  They are not difficult commands but despite that fact I quickly put together three scripts so I don’t need to remember the details.

sudo systemctl start tomcat

sudo systemctl stop tomcat

sudo systemctl status tomcat


I had a few small difficulties with tomcat once it was installed. The problems were not Tomcat itself but rather using some of the scripts that ship with tomcat.  The script that I was specifically having problems with was which is located in the /opt/tomcat/bin directory.

In addition to the setup described in the tutorial I also did the following

cd /opt/tomcat
chmod 755 bin
cd /opt/tomcat/bin
chmod 755 *sh
chmod 754 *jar

This was only the start. I tried running the script and ended up seeing the following error.

Using CATALINA_BASE:   /opt/apache-tomcat-8.5.11
Using CATALINA_HOME:   /opt/apache-tomcat-8.5.11
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.11/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-8.5.11/bin/bootstrap.jar:/opt/apache-tomcat-8.5.11/bin/tomcat-juli.jar
Error: Could not find or load main class org.apache.catalina.util.ServerInfo

This last little issue was due to the jar files not being readable by a non-tomcat user (ie world file permissions)

Once I changed the permissions to 644 it was then possible to run the version script

Using CATALINA_BASE:   /opt/apache-tomcat-8.5.11
Using CATALINA_HOME:   /opt/apache-tomcat-8.5.11
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.11/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-8.5.11/bin/bootstrap.jar:/opt/apache-tomcat-8.5.11/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.11
Server built:   Jan 10 2017 21:02:52 UTC
Server number:
OS Name:        Linux
OS Version:     4.4.0-53-generic
Architecture:   i386
JVM Version:    1.8.0_121-b13
JVM Vendor:     Oracle Corporation
This entry was posted in programming. Bookmark the permalink.