Apache Tomcat Install

Prerequisites

Download Tomcat

Download latest appropriate version and copy it to /tomcat on your target server.

The Core tar.gz file is recommended

Create Tomcat User

Linux Users & Groups

As 'root'...

useradd --system --create-home --user-group --home-dir /opt/tomcat --shell /bin/false --comment "Apache Tomcat" tomcat

cat /etc/passwd | grep tomcat

cat /etc/group | grep tomcat

Install Tomcat

As 'root'...

tar xvf apache-tomcat-9*.tar.gz -C /tomcat

ln -s /tomcat/apache-tomcat-9.0.54 /tomcat/latest

rm /tomcat/apache-tomcat-9.0.54.tar.gz

chown -R tomcat:tomcat apache-tomcat-9.0.54

chown -R tomcat:tomcat latest

chmod o+x /tomcat/latest/bin/

Set Environment

export JAVA_HOME=/bin

export CATALINA_HOME=/tomcat/latest

export CATALINA_BASE=$CATALINA_HOME

Add these variables to the end of /tomcat/.bash_profile

chown -R tomcat:tomcat /tomcat/.bash_profile

Configure systemd

This is optional, but recommended

As 'root'...

vi /etc/systemd/system/tomcat.service

systemctl daemon-reload

Enable Tomcat after Boot

systemctl enable tomcat

Start Tomcat

systemctl start tomcat

Check Status

systemctl status tomcat

When Tomcat is running, the following URL should be available...

http://localhost:8080/

Next Steps

Bibliography