An Open Source Community
An Open Source Community

Tomcat Installation on Linux RHEL and Centos 7

Apache Tomcat Installation on Linux (RHEL 7 and Centos 7) in Highly Secure Mode

Apache Tomcat often referred to as Tomcat Server, is an open-source Java Servlet Container developed by the Apache Software Foundation (ASF). Tomcat Installation on Linux is very easy and quick .

  • Set hostname of Linux machine as per your requirement like we are setting below:
[[email protected] ~]# hostnamectl set-hostname
  • Set IP mapping of your machine hostname in /etc/hosts:
[email protected] ~]# echo jenkins >> /etc/hosts
  • Setting JAVA:

1: Download latest stable JDK and extract

[[email protected] ~]# tar -xvf jre-8u121-linux-x64.tar.gz

2: Create directory for java

[[email protected] ~]# mkdir /usr/java

3: Move Java folder in to /usr/java

[[email protected] ~]# mv jre1.8.0_121 /usr/java/

4: Export Java home and bin like below,

[[email protected] ~]# export JAVA_HOME=/usr/java/jre1.8.0_121
[[email protected] ~]# export PATH=$PATH:$JAVA_HOME/bin/

5: Check Java version,

[[email protected] bin]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
  • Setting up tomcat:

1: Download latest stable tomcat zip file and unzip it

[[email protected] ~]# unzip

2: Create tomcat user and group

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

3: Create tomcat home directory

[[email protected] ~]# mkdir /opt/tomcat

4: Move tomcat file into tomcat home

[[email protected] ~]# mv apache-tomcat-7.0.76/* /opt/tomcat/

5: Setup required file and directory permission on tomcat file

[[email protected] ~]# chgrp -R tomcat /opt/tomcat
[[email protected] ~]# chmod -R g+r /opt/tomcat/conf
[[email protected] ~]# chmod g+x /opt/tomcat/
[[email protected] ~]# chmod g+x /opt/tomcat/bin/*
[[email protected] ~]# chmod -R g+w /opt/tomcat/logs
[[email protected] ~]# chmod -R g+w /opt/tomcat/webapps/
[[email protected] ~]# chmod -R g+w /opt/tomcat/work/
[[email protected] ~]# chmod -R g+w /opt/tomcat/temp/

6: Create systemd service file for tomcat

vi /etc/systemd/system/tomcat.service

# Systemd unit file for tomcat
Description=Apache Tomcat Web Application Container


Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'

ExecStop=/bin/kill -15 $MAINPID



7: Start tomcat service

[[email protected] ~]# systemctl start tomcat

8: Check tomcat service status

[[email protected] ~]# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2017-03-24 00:56:17 IST; 35s ago
Process: 12259 ExecStart=/opt/tomcat/bin/ (code=exited, status=0/SUCCESS)
Main PID: 12266 (java)
CGroup: /system.slice/tomcat.service
└─12266 /usr/java/jre1.8.0_121/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/ -Djava.util.l...

9: Enable tomcat service on system startup

[[email protected] tomcat]# systemctl enable tomcat

Leave a comment

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

One thought on “Tomcat Installation on Linux RHEL and Centos 7”