Installing Tomcat 9 behind Apache on CentOS 7

There are a number of posts on how to do this. I have created this post mostly for my own records so I know I will continue to have a record of what I have done.

Setup

Ensure you have at least JDK 8, I have the RPM “java-1.8.0-openjdk.x86_64” installed by this point.

Create a system user account to run tomcat:

useradd -r tomcat –shell /bin/false

Download the Tomcat 9 zip file, in my case this was “apache-tomcat-9.0.22.zip” which I downloaded to “/var/tmp” and then extract it and set permissions:

cd /var/tmp
unzip apache-tomcat-9.0.22.zip -d /opt
mv /opt/apache-tomcat-9.0.22 /opt/tomcat9
chown -R tomcat.tomcat /opt/tomcat9

Now create a service file:

/etc/systemd/system/tomcat.service

For me this looked like:

Now set the correct permissions for the Tomcat startup script, enable the service and finally start the service:

cd /opt/tomcat9/bin
chmod 774 *.sh
systemctl enable tomcat.service
systemctl start tomcat.service

At this point Tomcat is running and you should be able to access it on port 8080 so:

http://centos7-base:8080/

References

Rose Hosting: Install Tomcat 9 on CentOS 7
https://www.rosehosting.com/blog/install-tomcat-9-on-centos-7/

Red Hat: Creating and Modifying systemd Unit Files
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-unit_files