Run Tomcat Server as a Service in CentOS 7

May 06, 2018 | 975 views | Comments

To make it more easier to start and stop an Apache Tomcat Server, run it as a service which can be performed by a "sudoer". To do this, a systemd service file must be created and installed. This is a follow-up tutorial of Install JAVA 1.8 and Tomcat Server 9 in CentOS 7.


Step 1. Create a "service" file inside the "system" folder.

Go inside the "systemd/system" folder.

$ cd /etc/systemd/system

Create the file using vi, you can use other linux-based text editor you like.

$ sudo vi tomcat.service

Copy/paste the following code into the tomcat.service file.

Description=Apache Tomcat 9 Web Application Container








Step 2. Restart the "systemctl" to have the new service take effect.

$ sudo systemctl daemon-reload


That's all!

Tomcat can now run as a service.


Start tomcat. Requires a "sudoer".

$ sudo service tomcat start


Stop tomcat. Requires a "sudoer".

$ sudo service tomcat stop



If you encounter a "Permission denied" issue, repeat "Step 7" of the tutorial Install JAVA 1.8 and Tomcat Server 9 in CentOS 7.

Step 7. Change group and ownership of the utarred folder "apache-tomcat-9.0.7" to both user tomcat, and group tomcat.

$ sudo chown tomcat:tomcat -R /opt/tomcat/apache-tomcat-9.0.7


Related Tutorials

Must Read