Linux centos7服务器安装自启动的tomcat服务

基本环境准备【Linux centos7服务器安装自启动的tomcat服务】jdk安装配置 。安装目录例如:/usr/JAVA/jdk1.8.0_05
Tomcat下载放到约定目录 。例如:/usr/local/dmstomcat

Linux centos7服务器安装自启动的tomcat服务

文章插图
 
tomcat做成系统服务把tomcat做成系统服务,就可以使用service systemctl 快速管理tomcat服务,自启动等 。
操作步骤/usr/lib/systemd/system/目录下新建文件dmstomcat.service
vi /usr/lib/systemd/system/dmstomcat.service
粘贴下面内容:
[Unit]Description=dmstomcatAfter=syslog.target network.target remote-fs.target nss-lookup.target [Service]Type=forkingEnvironment='JAVA_HOME=/usr/java/jdk1.8.0_05'Environment='CATALINA_PID=/usr/local/dms/bin/tomcat.pid'Environment='CATALINA_HOME=/usr/local/dms'Environment='CATALINA_BASE=/usr/local/dms'Environment='CATALINA_OPTS=-Xms2048M -Xmx2048M -server -XX:+UseParallelGC'WorkingDirectory=/usr/local/dms/ExecStart=/usr/local/dms/bin/startup.shExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target设置为开启机启动:systemctl enable dmstomcat
常用服务命令:
启动服务:systemctl start dmstomcat停止服务:systemctl stop dmstomcat重启服务:systemctl restart dmstomcat检查状态:systemctl status dmstomcat



    推荐阅读