Before you begin
All the following commands must be executed with super-user privileges.
Procedure
-
Create the service file with the following command:
touch /etc/systemd/system/tomcat.service
-
Assign the relevant rights to the file you created:
chmod 664 /etc/systemd/system/tomcat.service
-
Paste the following content in the file while adapting it to your
configuration:
[Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/usr/lib/jvm/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID [Install] WantedBy=multi-user.target
-
Reload the service daemon:
systemctl daemon-reload
-
Start the service:
systemctl start tomcat.service