Install Apache Tomcat 9 on CentOS 7 / RHEL 7 / Ubuntu 16.04

Apache Tomcat is free and open source Web server and Servlet container founded by Apache Software Foundation (ASF). It provides the required Java web Server platform for running the Java code. One of the prerequisite of Apache Tomcat 9 is “Java 8“.

In this article we will walk through the installation steps of Apache Tomcat 9 on CentOS 7.x/ RHEL 7.x and Ubuntu 16.04.

Step:1 Install Java 8 on CentOS 7.x and RHEL 7.x

Java 8 packages are available in the defaults CentOS and RHEL repositories, run the below yum command from the console.

[[email protected] ~]# yum install java-1.8.0

Run the beneath command to check Java version :

[[email protected] ~]# java -version
openjdk version "1.8.0_101"
OpenJDK Runtime Environment (build 1.8.0_101-b13)
OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
[[email protected] ~]#
Install Java 8 On Ubuntu 16.04 / 16.10

Java 8 is also available in Ubuntu 16.04/16.10 apt repositories, run the following apt command to install Java 8

[email protected]:~$ sudo apt update
[email protected]:~$ sudo apt install openjdk-8*

Check Java version

[email protected]:~$ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
[email protected]:~$

Step:2 Download the Apache Tomcat 9 tar.gz file

We can download Apache tomcat 9 tar.gz either from its official Web site or using wget command from the terminal.

Downloading Tomcat from the terminal

[[email protected] ~]# wget

Step:3 Extract the downloaded file and set CATALINA_HOME variable

Run the beneath tar command to extract Apache tomcat 9 under the /opt folder.

[[email protected] ~]# tar -zxpvf apache-tomcat-9.0.0.M17.tar.gz -C /opt/
[[email protected] ~]# cd /opt/
[[email protected] opt]# mv apache-tomcat-9.0.0.M17.tar.gz tomcat

Before starting the Tomcat Service let’’s first set the required CATALINA_HOME environment variable using below commands :

[[email protected] ~]# echo "export CATALINA_HOME='/opt/tomcat/'" >> ~/.bashrc
[[email protected] ~]# source ~/.bashrc
[[email protected] ~]#

Step:4 Specify the Users for Manager GUI Page and Admin Page Access.

By default no user or account is allowed to access Manager GUI Page and Admin Page. So to grant access to the users add the following lines in the file “/opt/tomcat/conf/tomcat-users.xml” just above <tomcat-users> tag

<!-- User linuxtechi who can access only manager section -->
<role rolename="manager-gui" />
<user username="linuxtechi" password="<Enter-Secure-Password>" roles="manager-gui" />

<!-- User Admin Who can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="<Enter-Secure-Password>" roles="admin-gui" />

Step:5 Start Tomcat Service

Run the beneath commands one after the another to start tomcat service.

[[email protected] ~]# cd /opt/tomcat/bin/
[[email protected] bin]# ./


To shutdown the tomcat service use below command

[[email protected] bin]# ./

Open the tomcat ports in firewall.

As we know by default tomcat runs on 8080 port so in case firewall is running on your Linux box then set the following rule to open 8080 port on CentOS 7.x and RHEL 7.x.

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=8080/tcp
[[email protected] ~]# firewall-cmd --reload
[[email protected] ~]#

Use the below command to open 8080 port in Ubuntu 16.04 / 16.10 firewall.

[email protected]:~# ufw allow 8080
Rule added
Rule added (v6)
[email protected]:~#

Note: You can skip this step if firewall is disabled on your server

Step:6 Access Apache Tomcat 9 page from the Web Browser

Open the web broswer type the following URL :


In my case ip address of my server is “”


Click on “Manager App” , It will prompt us for the User name and password, specify the user’s credentials whatever we set in the file ‘tomcat-users.xml


Similarly We can view the Server Status by clicking on the option “Server Status

Scenario : if you have installed Tomcat on remote server and want to access ‘Manger App’ and ‘Server Status’ on your local system’s web browser for that we need to create a file “manager.xml” under the folder “/opt/tomcat/conf/Catalina/localhost/” with the following content.

[email protected] ~]# cd /opt/tomcat/conf/Catalina/localhost/
[[email protected] localhost]# vi manager.xml
<Context privileged="true" antiResourceLocking="false"
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />

Save and Exit the file

That’s all, Hope you like Tomcat 9 installation Steps 🙂

15 thoughts on “Install Apache Tomcat 9 on CentOS 7 / RHEL 7 / Ubuntu 16.04”

  1. Great tutorial.

    I was looking for instructions on how to create a systemd init file to start/stop/restart Tomcat. I found the solution here ‘’

    • Steps mentioned in the article would be same except the firewall rule. In CentOS 6.x you have to write a iptable rule instead of firewall-cmd command

  2. when i go for download tomcat i face this issue

    HTTP request sent, awaiting response… 404 Not Found
    2017-01-23 16:22:20 ERROR 404: Not Found.

    • Hi Rehan,

      Try beneath command from the terminal. It should work and the same has been updated in the article as well.

      # wget “”

  3. I have followed above all steps it works but when click on Manager app or server status. it ask username and password again if you entered in it. and not open Manager app gui.

  4. I detected an error in the sptep 3… the last command should be “mv apache-tomcat-9.0.0.M17 tomcat”(without .tar.gz) no “mv apache-tomcat-9.0.0.M17.tar.gz tomcat”

  5. Sir,
    I have configured apache-tomcat-9.0.31.tar.gz on RHEL 7.6 remote server at path /usr/local/tomcat9/ and followed ditto steps as you described beautifully.
    Even I have created manager.xml file at path /opt/tomcat/conf/Catalina/localhost/ and added given content but getting errors on Server Status, Manager App and Host Manager button click.

    ‘HTTP Status 404 – Not Found’ for /manager/status, /manager/html and
    ‘403 Access Denied’ for /host-manager/html

    Please guide.


Leave a Comment