Back to home

Tomcat Manager Application for Tomcat 8 + 9

Introduction

Your instances do not come with the Tomcat 8 Manager Application or Tomcat 9 Manager Application application out of the box.

We’ll first have to extract this application from a fresh Tomcat 8 installation archive, and to copy it in our instance (this application is unfortunately not available in a standalone version). We’ll then set a tomcat user with the correct credentials to access it.

What version of Tomcat am I using?

First of all, we need to know what Tomcat version we are on.
Launch the following command to know what is the current version of Tomcat on your system:

java -cp /usr/share/tomcat8/lib/catalina.jar org.apache.catalina.util.ServerInfo | grep "Server number"
# Server number: 8.0.32.0

or

java -cp /usr/share/tomcat9/lib/catalina.jar org.apache.catalina.util.ServerInfo | grep "Server number"
# Server number: 9.0.16.0

In the example above, we are using Tomcat 9.0.16.0. We’ll therefore download the correct Tomcat 9 archive in the next step.

Getting the application

All the Tomcat versions are located here: http://archive.apache.org/dist/tomcat. Browse the version you need, and replace it in the code snippet below:

cd ~/<instance-name>/
export ARCHIVE_URL=http://archive.apache.org/dist/tomcat/tomcat-9/v9.0.16/bin/apache-tomcat-9.0.16.tar.gz
wget $ARCHIVE_URL
tar xvf apache-tomcat-9.0.16.tar.gz
mv apache-tomcat-9.0.16/webapps/manager/ webapps/
rm -rf apache-tomcat-9.0.16*

Setting up the credentials

As specified in the reference documentation, we first need to create a manager.xml file in ~/<instance-name>/conf/Catalina/localhost/:

#/home/www-data/<instance-name>/conf/Catalina/localhost/manager.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/manager" antiResourceLocking="false" privileged="true" />

As a second step, we need to add our user to ~/<instance-name>/conf/tomcat-users.xml:

#/home/www-data/<instance-name>/conf/tomcat-users.xml
<tomcat-users>
<role rolename="manager-gui"/>
<user username="manager" password="random-password" roles="manager-gui"/>
</tomcat-users>

After this changes, restart your instance:

systemctl --user restart user-tomcat@<instance-name>

The Tomcat Manager Application should now be accessible under http://your-url.ch/manager/html with the credentials mentioned in tomcat-users.xml.

Didn't find what you were looking for?

Contact our support:

+41 44 637 40 40 Support Portal support@nine.ch