CentOS 7 Tomcat开机自启动配置
CentOS 7 Tomcat开机自启动配置 配置开机运行 Tomcat增加启动参数 Tomcat需要增加一个pid文件,在 $CATALINA_HOME/bin 目录下面,增加 setenv.sh 配置,catalina.sh启动的时候会调用,同时配置Java内存参数。添加如下命令: [root@vps bin]# vim setenv.sh #Tomcat startup pid #set Java runtime environment variable export JAVA_HOME=/usr/java/jdk1.8.0_191-amd64 export PATH=$PATH:$JAVA_HOME/bin export CATALINA_HOME=/developer/apache-tomcat-7.0.91 export CATALINA_BASE=/developer/apache-tomcat-7.0.91 #add Tomcat pid CATALINA_PID="$CATALINA_BASE/tomcat.pid" #add Java opts JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m" 注意: 配置开机运行时,需要再次添加 JAVA_HOME 增加 tomcat.service 在/usr/lib/systemd/system目录下增加tomcat.service,目录必须是绝对目录,添加如下命令: [root@vps bin]# vim /usr/lib/systemd/system/tomcat.service # conf service desc ,set do this after network started [Unit] Description=tomcat After=syslog.target network.target remote-fs.target nss-lookup.target # conf service pid, start,stop and restart [Service] Type=forking PIDFile=/developer/apache-tomcat-7.0.91/tomcat.pid ExecStart=/developer/apache-tomcat-7.0.91/bin/startup.sh ExecStop=/bin/kill -s QUIT $MAINPID ExecReload=/bin/kill -s HUP $MAINPID PrivateTmp=true # conf user [Install] WantedBy=multi-user.target [unit]: 配置了服务的描述,规定了在network启动之后执行, ...