1、修改/usr/local/apache-tomcat-8.0.32/bin/setclasspath.sh文件,向文件头部添加JAVA_HOME和JRE_HOME环境变量,如下图:
![45d862b5d62f1aebba7c76d0c72bdc5e.png](https://i-blog.csdnimg.cn/blog_migrate/453ce1c91fb907c421db324ffd0e893c.jpeg)
2、/etc/systemd/system 目录创建tomcat.service文件,文件内容如下:
[Unit]
Description= Apache Tomcat 8.0.32
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/apache-tomcat-8.0.32/bin/startup.sh
ExecStop=/usr/local/apache-tomcat-8.0.32/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
PrivateTmp=True
[Install]
WantedBy=multi-user.target
3、设置开机启动:systemctl enable tomcat
4、启动服务:systemctl start tomcat
5、查询服务状态:systemctl status tomcat