# How to install Apache Tomcat on CentOS 7

Learn how to install and use Apache Tomcat on [CentOS](https://www.ionos.com/digitalguide/server/know-how/what-is-centos-versions-system-requirements/ "What is CentOS? Versions &amp; system requirements") 7. Apache Tomcat is a Java Servlet container developed by Apache to which allows you to deploy Java servlets and JSPs. Apache Tomcat also functions as a [web server](https://www.ionos.com/digitalguide/server/know-how/web-server-definition-background-software-tips/ "Web server: definition, background, software tips"), which is able to support small to medium-sized websites.

This tutorial also covers how to install and use the Tomcat Web Admin Manager, which allows you to manage Tomcat and virtual hosts from a web browser.

## Requirements

- A Cloud Server running Linux (CentOS 7)
- If you have a firewall, you will need to allow access to port 8080.

## Install Tomcat

Installing Tomcat on CentOS 7 requires one simple command:

```none
sudo yum install tomcat
```

This will install Tomcat and its dependencies, including Java.

There are several additional packages which many users, particularly those who are new to Tomcat, will find useful. Install them with the command:

```none
sudo yum install tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc
```

This will install:

- The Tomcat root webpage (tomcat-webapps)
- The Tomcat Web Admin Manager (tomcat-admin-webapps)
- The official online Tomcat documentation (tomcat-docs-webapp and tomcat-javadoc)

If your server is running Apache, stop it with the command:

```none
sudo systemctl stop httpd
```

Start Tomcat with the command:

```none
sudo systemctl start tomcat
```

And enable Tomcat to automatically start if the server is rebooted:

```none
sudo systemctl enable tomcat
```

You can verify that Tomcat is running by visiting the URL http://example.com:8080 in a web browser. You will see the Tomcat welcome page, which includes links to the Tomcat documentation which you installed in the previous step.

[![Image: Tomcat welcome page](https://www.ionos.com/digitalguide/fileadmin/_processed_/d/f/csm_tomcat-1_46daf64d59.webp "Tomcat welcome page")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tomcat-1.jpg)      ##  Use the Tomcat Web Admin Manager

In order to use Tomcat's web management interface, you will need to create a user. Open the tomcat-users.xml file with the command:

```none
sudo nano /usr/share/tomcat/conf/tomcat-users.xml
```

Scroll down to below the line which reads &lt;tomcat-users&gt; and add the information for your user account:

```none
<user username="[username]" password="[password]" roles="manager-gui,admin-gui"/>
```

For example, to add the user jdoe with password En4EW25eI0 this section will read:

```none
<tomcat-users>
<user username="jdoe" password="En4EW25eI0" roles="manager-gui,admin-gui"/>
```

Save and exit the file. Restart the Tomcat service for the changes to take effect:

```none
sudo systemctl restart tomcat
```

In a browser, visit the URL http://example.com:8080 to see the Tomcat welcome page. Click the **Manager App** link.

[![Image: Tomcat manager app link](https://www.ionos.com/digitalguide/fileadmin/_processed_/4/a/csm_tomcat-2_dcc4561911.webp "Tomcat manager app link")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tomcat-2.jpg)      You will be prompted to log in with the username and password you created.

[![Image: Tomcat web manager](https://www.ionos.com/digitalguide/fileadmin/_processed_/7/6/csm_tomcat-3_8b56d52d1c.webp "Tomcat web manager")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tomcat-3.jpg)      From this page you can stop, reload, and run diagnostics on various Java applications.

## Manage Virtual Hosts

To manage virtual hosts through the Web Application Manager, scroll down and click the /host-manager link.

[![Image: Tomcat host manager](https://www.ionos.com/digitalguide/fileadmin/_processed_/2/d/csm_tomcat-4_08f07c0d9d.webp "Tomcat host manager")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/tomcat-4.jpg)      This will take you to the Tomcat Virtual Host Manager, where you can add and manage virtual hosts to your Tomcat server.


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/apache-tomcat-on-centos/](https://www.ionos.com/digitalguide/server/configuration/apache-tomcat-on-centos/) for AI/LLM consumption.