Install Apache Tomcat 9 on Ubuntu Server 17.10

In this post we will walk through how to install Apache Tomcat 9 on Ubuntu Server 17.10.

This will be a quick post on installing Apache Tomcat 9.  I have several articles (and a book or two) that deal with automating deploying Tomcat applications to a Tomcat server using Puppet and other automation.  If you don’t have a Tomcat server setup then this post will get you started.


First we need to install Java and some building tools that will definitely need later.

# apt install openjdk-9-jdk

# apt install build-essential

Installing Apache Tomcat 9

Lets begin by downloading the binaries for Ubuntu and moving them to a good location.


# tar -xzvf apache-tomcat-9.0.4.tar.gz

# mkdir /usr/local/bin/tomcat

# cp -aR apache-tomcat-9.0.4/* /usr/local/bin/tomcat

Now we need to make sure the permissions are good.

chown -R tomcat:tomcat /usr/local/bin/tomcat

SystemD Service Management

Now we need to configure SystemD to be able to manage our Tomcat service for us.  Create a new file /etc/systemd/system/tomcat.service and enter the following contents:

# Systemd unit file for tomcat
Description=Apache Tomcat Web Application Container


Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'

ExecStop=/bin/kill -15 $MAINPID



Reload SystemD configurations and start our new Tomcat service.

# systemctl daemon-reload

# systemctl start tomcat

# systemctl enable tomcat

Fixing Tomcat Security

Now that we have Tomcat installed we have to configure access to the management applications.  First we will create an admin user that we can use to login to the management applications.

vim /usr/local/bin/tomcat/conf/tomcat-users.xml

In the tomcat-users section add a line for our new user.

    <user username="admin" password="topsecret" roles="manager-gui,admin-gui"/>

Next we need to allow access to the management applications from any server because by default it only allows access from localhost.

# vim /usr/local/bin/tomcat/webapps/manager/META-INF/context.xml

Delete this line:

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

And do the same for this file:

# vim /usr/local/bin/tomcat/webapps/host-manager/META-INF/context.xml

Finally, restart tomcat.

# systemctl restart tomcat

Web Interface

You can now access the web interface and login with your information.

install tomcat 9
install tomcat 9

We now know how to install Apache Tomcat 9 on Ubuntu 17.10


I hope you have enjoyed this article, if so please leave a comment below.  For more articles, please signup for the AdminTome Blog below.  Also please feel free to share the article to your friends using the buttons to the left.  Thanks again for reading this post.