How to Install Apache Tomcat 9 on CentOS 7

Server Management Services

In this article we will guide you through the steps of installing Apache Tomcat 9 on an CentOS 7 VPS. Apache Tomcat is the most popular and widely used Java application server. It is an open source web server and servlet container developed by the Apache Software Foundation. It executes Java servlets and renders Web pages that include Java Server Page coding. Tomcat has been downloaded more then 10 millions times and it powers mission-critical sites like WallMart, The Weather Channel and much more. Installing Apache Tomcat 9 on CentOS 7 is fairly easy task, and it should’t take more then 10 minutes for Tomcat 9 to be installed on your CentOS 7 based virtual server.

Apache Tomcat 9 is built on top of the latest Java EE 8 specifications such as: Servlet 4.0, EL 3.1, JSP 2.4 and WebSocket 1.2. Also it has a lot of bug and security fixed and major improvements such as the following:
– implements HTTP/2 (requires the APR/native library)
– supports TLS virtual hosting
– Allows OpenSSL performance with NIO/NIO2 APIs
– using OpenSSL for TLS with the JSSE connectors
– SNI and multiple certificates supported by all connectors
– OpenSSL engine option for NIO and NIO2
and much more…

1. Login and update the system

Login to your CentOS 7 VPS via SSH as user root

ssh root@IP_Address -p7022

and make sure that all installed packages are up to date

yum -y update

2. Install Java 8

Apache Tomcat 9 requires Java 8 or newer to be installed on the server. Java 8 packages are available in the default CentOS 7 repositories. Run the following command to install Java 8

yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64

This will install Java 8 and all its dependencies. Once the installation is completed, you can check the installed version using the following command

java -version

You should get the following output:

openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

3. Install Tomcat 9

Go to the official Apache Tomcat website and download the most recent version of the software to your server. At the moment the most recent release is version 9.0.7.


Download the sha512 checksum of the file


Run the following command to generate the sha512 checksum of the file


And compare if the sha512 checksum is the same as the checksum the file contains

72e042d28e4ac43310047bdb07a2b761656d4216b8702904e2878dcd6e1b659f92e322420f844f5e76109df9c70ac87ca6f4762cdf3a11100680cc2f9db9fdb5 *

If the checksums are the same like in the output above, unpack the downloaded zip archive

unzip -d /opt

This will create a new directory named ‘apache-tomcat-9.0.7’. We will rename it to something simpler

cd /opt
mv apache-tomcat-9.0.7/ tomcat

Run the following commands to set the CATALINA_HOME environment variable

echo "export CATALINA_HOME='/opt/tomcat/'" >> ~/.bashrc
source ~/.bashrc

It is not recommended to run Apache Tomcat as user root, so we will create a new system user which will run the Tomcat server

useradd -r tomcat --shell /bin/false

and change the ownership of all Tomcat files

chown -R tomcat:tomcat /opt/tomcat/

Create the a systemd file with the following content

nano /etc/systemd/system/tomcat.service

Description=Apache Tomcat 9



Save the file and run the following command to reload the systemd manager configuration

systemctl daemon-reload

4. Configure Tomcat 9

Now you can start the Apache Tomcat 9 server and enable it to start on boot time

systemctl start tomcat
systemctl enable tomcat

You can check the status of the Tomcat 9 server and confirm that it is properly installed by executing the following command

systemctl status tomcat


● tomcat.service - Apache Tomcat 9
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (exited) since Wed 2018-04-11 05:59:13 CDT; 2min 31s ago
Process: 1091 ExecStart=/opt/tomcat/bin/ (code=exited, status=0/SUCCESS)
Main PID: 1091 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/tomcat.service
└─1106 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/ -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048

You should now be able to access the Tomcat server in your favorite web browser. Apache Tomcat by default is listening on port 8080, so open the browser and navigate to http://IP_address:8080 and you will see the home page of Apache Tomcat.

5. Create Tomcat 9 user account

You can create a new Tomcat user in order to be able to acess the Tomcat manager. Open the tomcat-users.xml file and add the following lines:

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

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

Don’t forget to replace PASSWORD with an actual strong password.

By default the Tomcat Manager is only accessible from a browser running on the same machine as Tomcat. If you want to remove this restriction, you’ll need to edit the Manager’s context.xml file, and comment out or remove the following line:

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

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

6. Restart Apache Tomcat 9

restart the Apache Tomcat server for the changes to take effect.

systemctl restart tomcat

7. Tomcat 9 Web Access

Now, you will be able to access the Apache Tomcat Manager by clicking the ‘Manager App’ button on the homepage, or directly at http://IP_address:8080/manager/html using user ‘admin’ and password ‘PASSWORD’

Installing Apache Tomcat-9 on CentOS 7Of course you don’t have to install Tomcat 9 on CentOS 7 if you use one of our optimized Tomcat 9 Web Hosting Solution, which case you can simply ask our expert Linux admins to install Tomcat 9 on CentOS 7 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to install Tomcat 9 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.