Apache Tomcat is an open-source web server that is intended to run Java site pages. It is generally widely deploy and powers different mission-basic web applications around the globaly.

In this article we show,how to install Apache Tomcat 8, which is the latest stable version of apache tomcat onto a centos 7.



Before additionally understanding, you have to:

You need to deploy a virtual CentOS 7 server.

You need to login this machine from your SSH terminal as a non-root sudo client.

Step 1: Update your CentOS system

First of all, you have to update the system to the latest stable status:

[[email protected] ~]# install epel-release
[[email protected] ~]# update -y && sudo reboot


Step 2: Install Java

You have to install Java SE 7.0 or later before Apache Tomcat can run legitimately. Here, I will install OpenJDK Runtime Environment 1.8.0 using YUM:

[[email protected] ~]# install java-1.8.0-openjdk.x86_64
[[email protected] ~]# yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64

Now, you can confirm your installation with:

[[email protected] ~]# java -version

You get the output like this-

openjdk version “1.8.0_91”
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

Step 3: Create a dedicated user for Apache Tomcat

For security purposes, you have to make a non-root user”tomcat” who has the member of tomcat group.

[[email protected] ~]# groupadd tomcat
[[email protected] ~]# mkdir /opt/tomcat
[[email protected] ~]# useradd -s /bin/nologin -g tomcat -d /opt/tomcat tomcat

Step 4: Download and install the latest Apache Tomcat

Under the “Paired Distributions” area and afterward the “Center” rundown, utilize the connection indicating the “tar.gz” document to make a wget summon:

[[email protected] ~]# cd ~
[[email protected] ~]# wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.0.33.tar.gz
[[email protected] ~]# tar -zxvf apache-tomcat-8.0.33.tar.gz -C /opt/tomcat --strip-components=1

Step 5: Setup proper permissions

Before you can run Apache Tomcat, you have to set proper permission for some of directory:cd /opt/tomcat

[[email protected] ~]# chgrp -R tomcat conf
[[email protected] ~]# chmod g+rwx conf
[[email protected] ~]# chmod g+r conf/*
[[email protected] ~]# chown -R tomcat logs/ temp/ webapps/ work/

[[email protected] ~]# chgrp -R tomcat bin
[[email protected] ~]# chgrp -R tomcat lib
[[email protected] ~]# chmod g+rwx bin
[[email protected] ~]# chmod g+r bin/*

Step 6: Setup a Systemd unit file for Apache TomcatAs an issue of accommodation, you should setup a Systemd unit petition for Apache Tomcat:

[[email protected] ~]# vi /etc/systemd/system/tomcat.service

Populate the file with:

Description=Apache Tomcat Web Application Container
After=syslog.target network.target



Environment=’CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC’
Environment=’JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom’

ExecStop=/bin/kill -15 $MAINPID



Save and quit:



Step 7: Install haveged, a security-related program

For security purposes, you should install haveged as well:

[[email protected] ~]# yum install haveged
[[email protected] ~]# systemctl start haveged.service
[[email protected] ~]# systemctl enable haveged.service

Step 8: Start and test Apache Tomcat

Now,you need to start the apache tomcat service.

[[email protected] ~]# systemctl start tomcat.service
[[email protected] ~]# systemctl enable tomcat.service

Then order to test Apache Tomcat in a web browser, you need to modify the firewall rules:

[[email protected] ~]# firewall-cmd --zone=public --permanent --add-port=8080/tcp
[[email protected] ~]# firewall-cmd --reload

Now you can test your apache tomcat is installed or not on your server by type below url in your browser:


In the case of nothing turns out badly, you will see the default Apache Tomcat first page.

Step 9: Configure the Apache Tomcat web management interface

To utilize the “Director App” and the “Host chief” in the Apache Tomcat web interface, you have to make an administrator client for your Apache Tomcat server:

[[email protected] ~]# vi /opt/tomcat/conf/tomcat-users.xml

Within the </tomcat-users …>…</tomcat-users> segment, insert a line to define a admin user:

<user username=”yourusername” password=”yourpassword” roles=”manager-gui,admin-gui”/>

Remember to replace “yourusername” and “yourpassword” with your own ones, the less common the better.

Save and quit:


For reflect changes which you have done. You need to restart the apache-tomcat server:

[[email protected] ~]# systemctl restart tomcat.service

Refresh  the Apache Tomcat first page from your web browser. Sign in the “Manger App” and the “Manager” utilizing the accreditation you had setup before.

The Apache Tomcat setup is finished. You would now be able to utilize it to convey your own applications.