Apache Tomcat

Environment Variables

  • CATALINA_HOME - location of Tomcat core installation, fex /usr/local/tomcat
  • JRE_HOME - location of the Java Runtime Environemnt (JRE)
  • JAVA_HOME - location of the Java Development Kit (JDK)

You can override variables for in /bin/setenv.sh The CATALINA_HOME and CATALINA_BASE variables cannot be changed here since they are used to find the program.

Add CATALINA_PID for example to set the location of the pid file, such as /var/run/catalina.pid

Starting / stopping

Two options:

/bin/catalina.sh start
/bin/catalina.sh stop


JAR files and external libraries can go in /lib, such as JDBC drivers.


Sites are installed in /webapps directory manually, or they can be installed through management interface running on the server available at /manager URL.

Ubuntu 16.04

Install OpenJDK 8:

apt-get -y install default-jre default-jre-headless

Install Tomcat 8:

apt-get -y install tomcat8

Tomcat by default listens on port 8080. To listen on port 80, two things need to change.

First, edit /etc/default/tomcat8 and set AUTHBIND to yes.

Second, update /etc/tomcat8/server.xml and change Connector port to 80. Then restart Tomcat.

Your Ubuntu install may or may not have authbind already installed, so add that package as well if needed:

apt-get -y install authbind
Admin Interface

The default homepage for the ROOT webapp comes with instructions on how to install the documentation, examples, and admin interfaces.

apt-get -y install tomcat8-docs tomcat8-examples tomcat8-admin

For accessing the manager and host-manager webapps, you will need to add users in /etc/tomcat/tomcat-users.xml. Here's an example that has user tomcat with password tomcat, who can manage both apps:

<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="admin-gui,manager-gui"/>

Once the users are added, restart Tomcat as normal:

/etc/init.d/tomcat restart