---
title: "How to Install Apache Tomcat 8 on CentOS 7"
description: "Apache Tomcat (sometimes simply referred to as Tomcat) is a popular open-source web server software used to set up Java-based server environments. The technologies used in Tomcat include Java..."
url: https://www.inmotionhosting.com/support/edu/software/how-to-install-apache-tomcat-on-centos-7/
date: 2020-06-12
modified: 2022-07-05
author: "InMotion Hosting Contributor"
categories: ["Software"]
type: post
lang: en
---

# How to Install Apache Tomcat 8 on CentOS 7

**Apache Tomcat** (sometimes simply referred to as **Tomcat**) is a popular open-source web server software used to set up Java-based server environments. The technologies used in Tomcat include Java Servlet, Java Server Pages, Java Expression Language, and WebSocket and provides an HTTP server environment ideal for running Java-based applications. In this article, we will outline how to install Tomcat on your CentOS 7 server. Please note, in order to perform the instructions on this guide, you will need [root SSH](https://www.inmotionhosting.com/support/amp/obtain-root-access/) access to your VPS or Dedicated server.

Before you begin, make sure you have [installed Java](https://www.inmotionhosting.com/support/product-guides/vps-hosting/install-java-on-centos/).

Topics Include:

- [Installing Apache Tomcat](#install)
- [Configuring Apache Tomcat](#configure)
- [Testing Apache Tomcat](#test)

Please note that this article only pertains to Private Cloud and Bare Metal servers. Also, [Control Web Panel (CWP)](https://www.inmotionhosting.com/support/edu/control-web-panel/apache-tomcat-cwp/) users can install this in a few clicks.

## Installing Apache Tomcat

1. First, ensure your machine and all related packages are up-to-date with the following commands:sudo yum install epel-releasesudo yum update -y && sudo reboot
2. Next, create a **tomcat user** and add it to the **tomcat group** with the following commands:sudo groupadd tomcatsudo mkdir /opt/tomcatsudo useradd -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
3. Next, change back to the home directory and download the **Tomcat .tar file** using the following commands:cd ~wget https://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.5.71.tar.gzNote: You will want to check the official Apache website for the latest stable release of the Tomcat software.

1. Once it has finished downloading, **extract** the Tomcat archive using the following command:sudo tar -zxvf apache-tomcat-8.0.33.tar.gz -C /opt/tomcat --strip-components=1
2. Once the extraction finishes, update the **file permissions** with the following commands:****cd /opt/tomcatsudo chgrp -R tomcat confsudo chmod g+rwx confsudo chmod g+r conf/*sudo chown -R tomcat logs/ temp/ webapps/ work/sudo chgrp -R tomcat binsudo chgrp -R tomcat libsudo chmod g+rwx binsudo chmod g+r bin/*
3. Next, you will need to set up a **systemd unit file** using the following command to open a text editor:sudo nano /etc/systemd/system/tomcat.service
4. With the text editor open, add the following code:Description=Apache Tomcat Web Application ContainerAfter=syslog.target network.targetType=forkingEnvironment=JAVA_HOME=/usr/lib/jvm/jreEnvironment=CATALINA_PID=/opt/tomcat/temp/tomcat.pidEnvironment=CATALINA_HOME=/opt/tomcatEnvironment=CATALINA_BASE=/opt/tomcatEnvironment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'ExecStart=/opt/tomcat/bin/startup.shExecStop=/bin/kill -15 $MAINPIDUser=tomcatGroup=tomcatWantedBy=multi-user.target
5. Press **Crtl + X** to save and quit the text editor.
6. Next, you will need to install and enable the *haveged* utility for security using the following commands:sudo yum install havegedsudo systemctl start haveged.servicesudo systemctl enable haveged.service
7. Once that is done, you can start Tomcat and enable it to start on reboot with the following commands:sudo systemctl start tomcat.servicesudo systemctl enable tomcat.service

## Configuring Apache Tomcat

1. Now that Tomcat has been installed, you will need to **configure the firewall** to allow browser access using the following commands:sudo firewall-cmd --zone=public --permanent --add-port=8080/tcpsudo firewall-cmd --reload
2. In order to start using the Tomcat **Graphical User Interface (GUI)**, you will need to configure the users file with a new username and password. In this example, replace **newusername** and **newpassword** with the username and password you want to use to log in to Tomcat. sudo nano /opt/tomcat/conf/tomcat-users.xml**Within**:</tomcat-users ...>...</tomcat-users>**Insert**:<user username="newusername" password="newpassword" roles="manager-gui,admin-gui"/>
3. **Restart Tomcat **sudo systemctl restart tomcat.service

## Testing Apache Tomcat

To test your Tomcat installation, you can simply visit your server IP followed by :8080. If the installation was successful, you should immediately see the login page.
