How to install Tomcat 8.5 on Debian 9 / Ubuntu 16.04 / Linux Mint 18


Apache Tomcat is an open source Java servlet container developed by the Apache Software Foundation (ASF). Tomcat implements Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a “pure Java” HTTP web server environment for running Java codes.

In Tomcat, you can deploy an application by using a war file through the Web Manager Application.

Here is the guide to install Apache Tomcat 8.5 on Debian 9 / Ubuntu 16.04.


First, switch to the root user.

su -


sudo su -

Tomcat requires Java JDK to be installed on the machine. You can either install Oracle JDK or OpenJDK.

READ: How to Install Oracle JAVA 8 on Debian 9
READ: How to Install Oracle JAVA 8 on Ubuntu 16.04 / LinuxMint 18

For this demo, I am going with OpenJDK.

apt-get -y install openjdk-8-jdk

Once Java is installed, you can verify the Java version by using the following command.

java -version


openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode

Create Tomcat Service Account

For best practice, Tomcat should never be run as privileged user (root). So, create a low-privilege user for running the Tomcat service.

groupadd tomcat
mkdir /opt/tomcat
useradd -g tomcat -d /opt/tomcat -s /bin/nologin tomcat

Download & Configure Apache Tomcat

You can download the latest version of the Apache Tomcat from the official website.


Extract the tomcat on to your desired (/opt/tomcat) directory.

tar -zxvf apache-tomcat-*.tar.gz
mv apache-tomcat-8.5.27/* /opt/tomcat/

Change the ownership of the extracted directory so that tomcat user can write files to it.

chown -R tomcat:tomcat /opt/tomcat/

Controlling Apache Tomcat


You can start and stop the Tomcat using the script which comes along with the package.

To start Tomcat service, go to the Tomcat directory and run:

cd /opt/tomcat/bin/


Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.

To stop Tomcat service, run:



We can also configure systemd to start the Tomcat service. Skip the below step in case you do not want to use systemd for managing Tomcat service.

Create a tomcat systemd service file. Green ones depend on the environment, so change them accordingly.

nano /etc/systemd/system/tomcat.service

Add the below information to Tomcat systemd service file.

Description=Apache Tomcat 8.x Web Application Container


Environment='CATALINA_OPTS=-Xms512M -Xmx1G'




Reload systemd daemon.

systemctl daemon-reload

To start the Tomcat service; run:

systemctl start tomcat

Check the status of Tomcat, run:

systemctl status tomcat

Enable the auto start of Tomcat service on system boot:

systemctl enable tomcat

Verify Apache Tomcat

By default, Tomcat runs on port 8080. Use can use the netstat command to check the port status.

netstat -antup | grep 8080


tcp        0      0  *               LISTEN      12224/java

READ: netstat command not found – Quick Fix


You may need to allow Tomcat server requests in the firewall so that we can access the application from the external network.

ufw allow 8080

Configure Apache Tomcat Web UI

Tomcat comes with the web-manager and Host Manager for managing Tomcat. Both Host Manager and Web Manager are password protected, and it requires a username and password to access.

Only the user with the manager-gui and admin-gui role is allowed to access web manager and host-manager respectively. Those two roles are defined in tomcat-users.xml file.

nano /opt/tomcat/conf/tomcat-users.xml

Place the following two lines (role and user definition) just above the last line.

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

For security reason, Web Manager and Host Manager is accessible only from the localhost, ie, from the server itself.

If you want to access managers from the remote system then you need to add your source network in allow list. To do that, edit the below two files.

nano /opt/tomcat/webapps/manager/META-INF/context.xml

nano /opt/tomcat/webapps/host-manager/META-INF/context.xml

Update the below line on both files with source IP from which your accessing the Web and Host Manager. .* will allow everyone to have access to managers.

allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|.*" />


You can allow only part of your network. For example, to allow only network, you can use the below values.

allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.*" />

Restart the Tomcat service.

systemctl restart tomcat

Access Tomcat

Open the web browser and point it to,


You would get the Tomcat default page; this confirms that Tomcat is successfully installed.

Install Tomcat 8.5 on Debian 9 - Tomcat 8 default page
Install Tomcat 8.5 on Debian 9 – Tomcat 8 default page

Web Manager: – Login Required. Username: admin, Password: password

Install Tomcat 8.5 on Debian 9 - Login for web manager
Install Tomcat 8.5 on Debian 9 – Login for web manager

Here, you can deploy a new application, deploy an application on specified context, start, stop, reload, and un-deploy an application.

Install Tomcat 8.5 on Debian 9 - Tomcat Web Manager
Install Tomcat 8.5 on Debian 9 – Tomcat Web Manager

Also, you can check the server status.

Install Tomcat 8.5 on Debian 9 - Tomcat Server Status
Install Tomcat 8.5 on Debian 9 – Tomcat Server Status

Host Manager: – Login Required. Username: admin, Password: password

Here, you can manage virtual hosts of Tomcat.

Install Tomcat 8.5 on Debian 9 - Tomcat Host Manager
Install Tomcat 8.5 on Debian 9 – Tomcat Host Manager

That’s All.

You might also like