tomcat开启自启动
Posted luck666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat开启自启动相关的知识,希望对你有一定的参考价值。
linux方式
#!/bin/bash #chkconfig: 2345 11 91 #description: Starts and Stops the Tomcat daemon. #by benjamin ############################################## #Startup script for Tomcat on Linux #filename tomcat.sh #Make sure the Java and the tomcat installation path has been added to the PATH JAVA_HOME=/data/jdk1.8.0_172/ #JDK安装目录 CATALINA_HOME=/data/tomcat/ #tomcat安装目录 export JAVA_HOME export CATALINA_HOME ############################################### start_tomcat=$CATALINA_HOME/bin/startup.sh #tomcat启动文件 stop_tomcat=$CATALINA_HOME/bin/shutdown.sh #tomcat关闭文件 start() { echo -n "Starting tomcat: " ${start_tomcat} echo "tomcat start ok." } stop() { echo -n "Shutting down tomcat: " ${stop_tomcat} echo "tomcat stop ok." } # See how we were called case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0
chmod 755 /etc/rc.d/init.d/tomcat #脚本授权 chkconfig --add /etc/rc.d/init.d/tomcat #加入系统服务中 chkconfig tomcat on #设定tomcat在各等级为on chkconfig --list tomcat #查看tomcat各个等级是否为on
windows方式:
Windows自启动(tomcat)
tomcat是安装版本,则在cmd输入service.msc找到
tomcat解压版,通过startup.bat手动启动tomcat后会出现对话框,如果机器意外重启,tomcat还需要手动重启,比较麻烦。(解压版需要添加环境变量和添加服务名称手动安装版直接services.msc找到tomcat服务右键属性找到启动类型选择自动即可)(解压版需要添加环境变量手动安装不需要添加环境变量)
解决:将tomcat安装成系统服务,设置启动方式为自启动。
1.安装tomcat服务 进入tomcat的bin目录下,运行service.bat install安装 E:\\tomcat_8083\\bin>service.bat install Installing the service \'Tomcat7\' ... Using CATALINA_HOME: "E:\\tomcat_8083" Using CATALINA_BASE: "E:\\tomcat_8083" Using JAVA_HOME: "E:\\Program Files (x86)\\jdk1.7.0_25_X64" Using JRE_HOME: "E:\\Program Files (x86)\\jdk1.7.0_25_X64\\jre" Using JVM: "E:\\Program Files (x86)\\jdk1.7.0_25_X64\\jre\\bin\\server\\jvm.dll" Failed installing \'Tomcat7\' service
如果提示Failed,可执行services.msc查看服务,看是否已存在Tomcat7服务,有则需要给新安装的服务指定其他名称,如下:
E:\\tomcat_8083\\bin>service.bat install Tomcat_8083 Installing the service \'Tomcat_8083\' ... Using CATALINA_HOME: "E:\\tomcat_8083" Using CATALINA_BASE: "E:\\tomcat_8083" Using JAVA_HOME: "E:\\Program Files (x86)\\jdk1.7.0_25_X64" Using JRE_HOME: "E:\\Program Files (x86)\\jdk1.7.0_25_X64\\jre" Using JVM: "E:\\Program Files (x86)\\jdk1.7.0_25_X64\\jre\\bin\\server\\j vm.dll" The service \'Tomcat_8083\' has been installed. 提示安装成功! 如果需要删除服务,则使用 E:\\tomcat_8085\\bin>sc delete Tomcat7 [SC] DeleteService 成功
以上是关于tomcat开启自启动的主要内容,如果未能解决你的问题,请参考以下文章
(转)如何在一台电脑上开启多个tomcat 和配置让系统识别哪个具体的tomcat