How To Install Apache Tomcat on CentOS 7

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

The Ultimate Guide to Installing and Configuring Apache Tomcat 7 on CentOS 7

Hello, tech enthusiasts! Darren here from Darren’s Tech Tutorials. Today, we’re diving into the heart of Java web application hosting by tackling one of the most reliable servers available: Apache Tomcat.

Tomcat is the go-to open-source implementation for core Java technologies like the Java Servlet, JavaServer Pages (JSP), and Java WebSocket. If you’re building serious Java web applications, you need a powerful server environment, and Tomcat on CentOS 7 is a fantastic combination.

In this comprehensive, step-by-step guide, we will walk through the entire installation and configuration process for Apache Tomcat 7 on a CentOS 7 machine, ensuring you’re ready to deploy your applications quickly and securely.

(Note: All commands shown in this tutorial are also available via the full tutorial link in the video description, allowing you to copy and paste easily.)


Step 1: Install the Base Tomcat Package

Our journey begins with installing the core Tomcat software using the yum package manager. This command fetches the base components needed to run the server.

Open your CentOS terminal and execute the following command:

sudo yum install tomcat

When prompted, press Y to confirm the installation and download all necessary dependencies.

Step 2: Configure the Tomcat JVM Heap Size

By default, Tomcat is allocated a relatively small amount of memory for the Java Virtual Machine (JVM). For production or development environments, it’s best practice to increase the memory allocation (specifically the maximum heap size, or Xmx) to improve stability and performance.

We need to edit the Tomcat configuration file, typically located at /usr/share/tomcat/conf/tomcat.conf. We’ll use vi for this task.

sudo vi /usr/share/tomcat/conf/tomcat.conf

Once inside the editor, press i to enter insert mode. Navigate to an empty line and paste in the following setting. This line sets the minimum heap size to 256MB and the maximum heap size (Xmx) to 1024MB (1GB).

JAVA_OPTS="-Xms256m -Xmx1024m"

After pasting the line, press Esc to exit insert mode, then type :wq and press Enter to write the changes and quit the file.

Step 3: Install Web Applications and Admin Tools

To make Tomcat management easier, we need to install the web applications package and the crucial Tomcat Admin GUI interface. These tools allow you to manage applications and sessions via a web browser.

Execute the following command to download these necessary components:

sudo yum install tomcat-webapps tomcat-admin-webapps

Again, press Y when prompted to confirm the download and installation.

While not strictly required for the server to run, having the official Tomcat documentation locally accessible is incredibly handy for troubleshooting and reference.

We will install the documentation web application and the accompanying Java documentation:

sudo yum install tomcat-docs-webapp tomcat-javadoc

Confirm the installation with Y.

Step 5: Configuring the Tomcat Manager GUI User

In order to access the powerful Web Application Manager (which we just installed in Step 3), we need to define a dedicated user with the correct security role. This is done by editing the tomcat-users.xml file.

Open the file using vi:

sudo vi /usr/share/tomcat/conf/tomcat-users.xml

Press i to enter insert mode. Locate the <tomcat-users> tags. We will add a new <user> definition between these tags.

For this tutorial, we will create an ‘admin’ user with the role manager-gui. Remember to use a strong, unique password for a production environment!

Paste the following user definition:

<user username="admin" password="password" roles="manager-gui"/>

Once done, press Esc, type :wq, and press Enter to save and exit.

Step 6: Starting and Enabling the Tomcat Service

With all the components installed and necessary configurations complete, it’s time to launch the server!

First, start the Tomcat service:

sudo service tomcat start

Next, ensure that Tomcat starts automatically whenever your CentOS server reboots. This is a critical step for maintaining uptime:

sudo chkconfig tomcat on

This ensures that the service is always available upon startup.

Step 7: Verification and Testing

The final step is to verify that the installation was successful and that we can access the server and the manager GUI. Tomcat defaults to running on port 8080.

Open your web browser (or use Firefox directly on the server if using a desktop environment) and navigate to the following address:

http://localhost:8080

You should see the official Apache Tomcat landing page!

Accessing the Manager App

To confirm your user configuration is correct, click the “Manager App” button on the Tomcat page. A login prompt will appear.

Use the credentials you defined in Step 5:

  • Username: admin
  • Password: password

If successful, you will be taken to the Web Application Manager interface, ready to deploy, monitor, and manage your Java applications!


That’s all there is to it! You have successfully installed and configured Apache Tomcat 7 on your CentOS 7 system.

If you followed along and got your manager interface running, congratulations! You now have a solid foundation for deploying dynamic web content.

If you found this tutorial useful, please do like this post and subscribe to Darren’s Tech Tutorials for more clear, accessible guides. If you ran into any issues, leave a comment below—I’m always happy to help troubleshoot! Happy coding!