How to Install Tomcat 8 on CentOS 7.0 (Multiple Instances)

Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation. It implements the Java Servlet, JavaServer Pages (JSP), Java Unified Expression Language and Java WebSocket specifications from Sun Microsystems and provides a web server environment for Java code to run in.

This article will guide you through the installation of Tomcat 8 on CentOS 7. Tomcat 8.0.9 is the first stable version of the 8th generation lunched on 25-06-2014, it’s aligned with Java EE 7. In addition to supporting updated versions of the Java EE specifications, Tomcat 8 includes a number of improvements compared to Tomcat 7 like support for Java Servlet 3.1, JavaServer Pages 2.3, Java Unified Expression Language 3.0 and Java WebSocket 1.0.

So let’s begin with the installation process:

1. Check if the correct version of Java is installed

JAVA is required for Tomcat to work, CentOS 7 comes with JAVA 7 witch is the needed version. To check if it is installed run:

# java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (rhel- u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

In case java is not installed on your system or you have version 1.6.x, you can install it by running:

# yum install java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel

2. Download Tomcat

You can find the latest version of  Tomcat at its download page. You can download it with wget and extract it with tar like this:

# cd /usr/share
# wget
# tar zxvf apache-tomcat-8.0.9.tar.gz

3. Add tomcat user & group

As it is not recommended to run Tomcat as root we will need to create an unprivileged user for it and set the apropiate owner of the tomcat folder:

# groupadd tomcat
# useradd -g tomcat -s /bin/bash -d /usr/share/apache-tomcat-8.0.9 tomcat
# chown -Rf tomcat.tomcat /usr/share/apache-tomcat-8.0.9/

4. Running Tomcat

To start tomcat we will first need to switch to the unprivileged user with:

# su – tomcat

And starting tomcat is as easy as running its startup script like this:

$ cd bin
$ ./

The output should look like:

Using CATALINA_BASE: /usr/share/apache-tomcat-8.0.9
Using CATALINA_HOME: /usr/share/apache-tomcat-8.0.9
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-8.0.9/temp
Using JRE_HOME: /
Using CLASSPATH: /usr/share/apache-tomcat-8.0.9/bin/bootstrap.jar:/usr/share/apache-tomcat-8.0.9/bin/tomcat-juli.jar
Tomcat started.

You should now be able to access it with a browser by either accessing http://localhost:8080 if this is a local computer or http://SERVER-IP:8080 if you are running it on a remote host.

Tomcat 8 on CentOS 7

To shutdown Tomcat you can simply run the shutdown script in the same folder like this:

$ ./

5. Setup user accounts

Finally you have to configure Tomcat users so they can access admin/manager sections. You can do this by adding the users in the conf/tomcat-users.xml file with your favorite text editor. Add this text to the file:

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

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

6. Running Multiple Instances of Tomcat (Optional)

Sometimes you need to run more than one instance of Tomcat on the same server. To do this, as root, go back to the /usr/share directory where you first downloaded tomcat and extract it again in a different folder like this:

# cd /usr/share
# mkdir apache-tomcat-2
# tar zxvf apache-tomcat-8.0.9.tar.gz -C apache-tomcat-2 --strip-components 1
# chown -Rf tomcat.tomcat /usr/share/apache-tomcat-2/

Now we need to open the config/server.xml file in the new installation folder and change the port numbers like this:

The shutdown port from:

<Server port="8005" shutdown="SHUTDOWN">


<Server port="8006" shutdown="SHUTDOWN">

The connector port from:

<Connector port="8080" protocol="HTTP/1.1"
redirectPort="8443" />


<Connector port="8081" protocol="HTTP/1.1"
redirectPort="8443" />

And the AJP port from:

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />

Now you can just switch back to the tomcat user and start the second instance like this:

# su - tomcat
$ cd /usr/share/apache-tomcat-2/bin/
$ ./
Using CATALINA_BASE: /usr/share/apache-tomcat-2
Using CATALINA_HOME: /usr/share/apache-tomcat-2
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-2/temp
Using JRE_HOME: /
Using CLASSPATH: /usr/share/apache-tomcat-2/bin/bootstrap.jar:/usr/share/apache-tomcat-2/bin/tomcat-juli.jar
Tomcat started.

You can now access the new instance of tomcat with your browser at http://localhost:8081/

Congratulation you now have Tomcat installed and ready to use!

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.


  1. Very helper post.

    Only following need correction.

    # useradd -g tomcat -s /bin/bash -d /usr/share/apache-tomcat-8.0.9 tomcat

    should be

    # useradd tomcat -g tomcat -s /bin/bash -d /usr/share/apache-tomcat-8.0.9 tomcat

  2. Very helpfull. But I spent a little time to understand that in Centos 7 iptables was replaced by firewall-cmd.. After that I`ve opened port 8080 :)

    And also will be helpful to add infrmation about how to run tomcat with ipv4

  3. Thank you for this page, it was useful. I am having an issue, after changing port to 80 from 8080, tomcat will listen only if started as root. If started as user "tomcat", then it does not listen on port 80 (or 8080 either). However with it being set to default 8080, tomcat will run under user "tomcat" and listen on 8080 without issue. But not on 80. Root only.

    I do not have apache running at the same time (installed but stopped). Any tips?