centos7 tomcat will be registered as a system service

First, prepare the environment

Operating System: CentOS Linux release 7.6.1810 (Core) 

tomcat:apache-tomcat-8.5.41.tar.gz

Second, edit catalina.sh

vim /usr/local/tomcat/bin/catalina.sh

Then enter: set number display line numbers

139 + shift + g-line 141 in FIG jump to add the following two rows 141 and 142

Red box in the next row up content CATALINA_BASE parameters, insert the picture:

 CATALINA_PID="CATALINA_BASE/tomcat.pid"

Then exit and save.

Third, create a file tomcat.service

vim /lib/systemd/system/tomcat.service

[Unit]
the Description = Tomcat
the After = network.target // specified start time

[Service]
Type=forking

Environment = "JAVA_HOME = / usr / local / jdk /" // Specifies the java environment variable

ExecStart = / usr / local / tomcat / bin / startup.sh // specify a startup script
ExecStop = / usr / local / Tomcat / bin / shutdown.sh
ExecReload = / bin / the kill -s HUP $ MAINPID
PrivateTmp to true =

[Install]
WantedBy=multi-user.target

 Fourth, start

Is set to open the machine starts: systemctl enable tomcat.service
start the service: systemctl start tomcat.service
stop service: systemctl stop tomcat.service
restart the service: systemctl restart tomcat.service
check the status: systemctl status tomcat

Guess you like

Origin www.cnblogs.com/yyxianren/p/10978034.html