A.在/usr/lib/systemd/system/目录下新建文件tomcat7.service,内容如下:
[Unit]
Description=Tomcat7
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment='JAVA_HOME=/usr/jdk1.7.0_72'
Environment='CATALINA_PID=/usr/apache-tomcat-7.0.70/bin/tomcat.pid'
Environment='CATALINA_HOME=/usr/apache-tomcat-7.0.70/'
Environment='CATALINA_BASE=/usr/apache-tomcat-7.0.70/'
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
WorkingDirectory=/usr/apache-tomcat-7.0.70/
ExecStart=/usr/apache-tomcat-7.0.70/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
B,设置为开启机启动:systemctl enable tomcat7
C,启停服务
1,启动服务:systemctl start tomcat7
2,停止服务:systemctl stop tomcat7
3,重启服务:systemctl restart tomcat7