Formerly known as Jakarta Tomcat, Apache Tomcat is a free and open-source web server that was founded by Apache Foundation. Unlike traditional web servers such as Apache or Nginx, Apache Tomcat is used to serve Java-based web applications. Tomcat version 9 was released on December 6th, 2018. Some of the improvements include Support for Java Servlet 3.1, Java WebSocket 1.0 and JavaServer Pages 2.3 to mention just but a few. In this guide, we are going to discuss how to install Apache Tomcat 9 on CentOS 7.
Table of Contents
Step 1: Install and configure Java
Before proceeding to install Apache Tomcat 9, ensure that the Java is installed. To install Java 8, run the below command.
# yum install java-1.8.0-openjdk-devel
Once successfully installed, you can verify its version by running the command.
# java -version
Step 2: Install Apache Tomcat 9
After successful installation of Java, now its time to install the latest version of Tomcat. By the time of writing this guide, the latest version of Tomcat is Tomcat 9.0.2. To get the latest version, head out to Tomcat’s official page .
To get started with installing Tomcat 9, navigate to
/usr/local directory as shown.
# cd /usr/local
Next download the latest Tomcat tarball file using
# wget https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.20/bin/apache-tomcat-9.0.20.tar.gz
Extract the tarball file.
# tar -xvf apache-tomcat-9.0.20.tar.gz
Once you have extracted the tarball, you will have 2 files as shown.
For simplicity’s sake, rename the extracted folder to the latest Tomcat version, in this case
# mv apache-tomcat-9.0.20 tomcat9
Next, configure CATALINA_HOME environment variable as shown.
# echo "export CATALINA_HOME="/usr/local/tomcat9"" >> ~/.bashrc # source ~/.bashrc
At this point, we are now set to launch Apache Tomcat 9. Run the following commands to start Tomcat 9.
# cd /usr/local/tomcat9/bin # ./startup.sh
To access the Tomcat server, open your web browser and browse your server’s IP.
Step 3: Setting up Tomcat 9 accounts
At this stage, you can only access Tomcat’s default web page. To access the Server Status, Host Manager, and Manager App we need to configure user accounts for managers and admins. These settings are found in
Open the file using the full file path as shown.
# vim /usr/local/tomcat9/conf/tomcat-users.xml
To add a user spikey with password Jupiter2030! with the role of manager-gui append the following lines.
<role rolename="manager-gui"> <user username=""spikey" password="Jupiter2030!" roles="manager-gui">
Alternatively, you can add an admin user called admin with admin-gui role and with a password Magnum2030!.
Finally, restart Tomcat and try accessing the Manager section. When asked for authentication, provide the credentials created in the above steps.
Apache Tomcat is the most popular web server for Java web applications and web services. We can install it easily on any server and run our Java applications.