https://blog.csdn.net/qq_31150365/article/details/89330366
参考连接
1,修改tomcat的catalina.sh文件
# vim /usr/local/tomcat/bin/catalina.sh
[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"
CATALINA_PID="$CATALINA_BASE/tomcat.pid" (这行是你新增加的,在上下两行之间 对于为什么要tomcat.pid 进程显示,不是很理解 )
# Ensure that any user defined CLASSPATH variables are not used on startup,
2,添加或修改tomcat.service
# vim /usr/lib/systemd/system/tomcat.service
修改成
[Unit]
Description=tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/jdk"
PIDFile=/usr/local/tomcat/tomcat.pid
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
JAVA_HOME和tomcat都是自己的jdk和tomcat的安装路径
修改保存
3,重新载入修改后配置文件,让设置生效。
systemctl daemon-reload
4,启动tomcat.service
systemctl start tomcat.service
5,查看tomcat.service运行状态
systemctl status tomcat.service
6,将tomcat.service添加的自启动
systemctl enable tomcat.service