How to Install Apache Tomcat on Debian 10

Install Apache Tomcat on Debian 10

In this article, we will have explained the necessary steps to install and configure Apache Tomcat on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Install Apache Tomcat on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install Java.

Apache Tomcat requires Java to be installed. We’ll install OpenJDK, which is the default Java development and runtime in Debian:

Check Java is already installed on your system running following command:

Step 3. Create Tomcat User.

Becuase of security reason Tomcat should not run as root user. So now you should create a non-root user for Tomcat typing following command:

Step 4. Install Tomcat.

First, download latest binaries from Tomcat Download Page. At the time creating this tutorial latest version is 9.0.14:

Once the download is completed, extract the Tomcat archive and move it to the /opt/tomcat directory:

To have more control over Tomcat versions and updates, we will create a symbolic link latest which will point to the Tomcat installation directory:

Run following command to give installation directory ownership to tomcat user and tomcat group:

Step 5. Create Systemd Unit File.

Run following command to create tomcat.service unit file inside /etc/systemd/system/ directory:

Add following line:

Notify systemd that we created a new unit file and start the Tomcat service by executing:

Step 6. Update The Firewall Settings.

If your firewall running on your Debian system and you want to access the tomcat interface from the outside of your local network you’ll need to open the port 8080:

Step 7. Configure Tomcat Web Management Interface.

Tomcat users and roles are defined in the tomcat-users.xml file. This file is a template with comments and examples describing how to configure the create a user or role:

Now add username and password for admin-gui and manager-gui. Make it sure you are setting strong username and password:

By default, Apache Tomcat restrict access to Manager and Host Manager apps to connections coming from the server also. You should remove these restrictions.

To change IP address restriction open following files. Open Manager app context file using below command:

Open Host Manager app context file using below command:

Add commnets as given in following file:

Remember to restart the Tomcat service each time you edit Tomcat configuration files for changes to take effect:

Step 8. Test the Tomcat Installation.

Open your browser and type: http://<your-domain_or_IP-address>:8080

You should get following output for successful installation:

Install Apache Tomcat on Debian 10

Now use Manager App visiting http://YOUR-DOMAIN_NAME_OR_IP-ADDRESS:8080/manager/html.

Install Apache Tomcat on Debian 10

Congratulation, you have learned how to install and configure Tomcat on Debian 10 Buster. If you have any question, please leave a comment below.