centos7设置tomcat8开机自动启动
1.前提是你已经安装好了tomcat服务。
2.配置Tomcat开机启动很简单,将Tomcat配置为系统服务并配置为开机启动即可。
首先将tomcat配置为系统服务:
创建tomcat8服务文件:
[root@ftpserver bin]# 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/java/jdk1.8.0_181-cloudera" Environment="CATALINA_HOME=/usr/tomcat/apache-tomcat-8.5.39" Environment="CATALINA_BASE=/usr/tomcat/apache-tomcat-8.5.39" Environment='CATALINA_PID=/usr/tomcat/apache-tomcat-8.5.39/bin/tomcat.pid' Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' WorkingDirectory=/usr/tomcat/apache-tomcat-8.5.39 ExecStart=/usr/tomcat/apache-tomcat-8.5.39/bin/startup.sh ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true
[Install] WantedBy=multi-user.target
3.接下来配置tomcat开机启动:
设置tomcat开机启动:systemctl enable tomcat
启动tomcat服务:systemctl start tomcat
查看服务中有没有tomcat:ps -ef |grep tomcat