在linux中設(shè)置tomcat開機(jī)自啟動(dòng)的方法
一、把tomcat配置成服務(wù)
1、新建服務(wù)腳本
vim /etc/init.d/tomcat
添加以下腳本內(nèi)容
#!/bin/bash # description: Tomcat9 Start Stop Restart # processname: tomcat9 # chkconfig: 234 20 80 CATALINA_HOME=/usr/local/apache-tomcat-9.0.8 case $1 in start) sh $CATALINA_HOME/bin/startup.sh ;; stop) sh $CATALINA_HOME/bin/shutdown.sh ;; restart) sh $CATALINA_HOME/bin/shutdown.sh sh $CATALINA_HOME/bin/startup.sh ;; *) echo 'please use : tomcat {start | stop | restart}' ;; esac exit 0
配置完后,保存退出
2、給新建的腳本設(shè)置執(zhí)行權(quán)限
chmod 744 /etc/init.d/tomcat
3、執(zhí)行以下命令進(jìn)行啟動(dòng)、停止 和 重啟tomcat服務(wù)
#啟動(dòng) service tomcat start #停止 service tomcat stop #重啟 service tomcat restart
試著用 service tomcat start 命令去啟動(dòng)tomcat服務(wù)時(shí),可能會(huì)報(bào)下圖的錯(cuò)
解決方案是:編輯 /usr/local/apache-tomcat-9.0.8/bin 下的 catalina.sh 文件
vim /usr/local/apache-tomcat-9.0.8/bin/catalina.sh
在最上方加上 :export JAVA_HOME="/usr/local/jdk1.8.0_60"
然后再試著執(zhí)行 service tomcat start 去啟動(dòng)tomcat服務(wù),發(fā)現(xiàn)ok了
二、配置tomcat服務(wù)開機(jī)自啟動(dòng)
向chkconfig添加 tomcat 服務(wù)的管理 [root@localhost ~]# chkconfig --add tomcat 設(shè)置tomcat服務(wù)自啟動(dòng) [root@localhost ~]# chkconfig tomcat on 查看tomcat的啟動(dòng)狀態(tài) [root@localhost ~]# chkconfig --list | grep tomcat 狀態(tài)如下: [root@localhost ~]# chkconfig –list | grep tomcat tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off 關(guān)閉tomcat服務(wù)自啟動(dòng):chkconfig tomcat off 刪除tomcat服務(wù)在chkconfig上的管理:chkconfig –del tomcat
這樣就成功配置了tomcat在linux下開機(jī)自啟動(dòng)
以上就是在linux中設(shè)置tomcat開機(jī)自啟動(dòng)的方法的詳細(xì)內(nèi)容,更多關(guān)于linux tomcat開機(jī)自啟動(dòng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Windows系統(tǒng)下Apache服務(wù)器無法啟動(dòng)的問題解決
這篇文章主要介紹了Windows系統(tǒng)下Apache服務(wù)器無法啟動(dòng)的問題解決,大多數(shù)情況下還是端口被占用的問題,需要的朋友可以參考下2015-07-07CentOS服務(wù)器環(huán)境下MySQL主從同步配置方法
這篇文章主要介紹了CentOS服務(wù)器環(huán)境下MySQL主從同步配置方法,較為詳細(xì)的分析了CentOS服務(wù)器環(huán)境下MySQL主從同步的配置操作步驟、相關(guān)命令、使用方法與注意事項(xiàng),需要的朋友可以參考下2018-03-03淺析Linux下利用coredump技術(shù)追查進(jìn)程崩潰原因
這篇文章主要介紹了Linux下利用coredump技術(shù)追查進(jìn)程崩潰原因,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12