您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“如何實(shí)現(xiàn)自啟動(dòng)Tomcat服務(wù)”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何實(shí)現(xiàn)自啟動(dòng)Tomcat服務(wù)”這篇文章吧。
如果我們使用war 包進(jìn)行部署項(xiàng)目的時(shí)候,需要把包放進(jìn)Tomcat的目錄下,為了使我們的服務(wù)能夠在服務(wù)器重啟的時(shí)候自動(dòng)啟動(dòng)起來,我們需要把Tomcat設(shè)置成自起服務(wù)。
配置 Tomcat 服務(wù)
新建服務(wù)腳本
[root@localhost ~]# vim /etc/init.d/tomcat
添加腳本內(nèi)容
#!/bin/bash # description: Tomcat7 Start Stop Restart # processname: tomcat7 # chkconfig: 234 20 80 CATALINA_HOME=/usr/local/tomcat/apache-tomcat-7.0.77 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
執(zhí)行腳本,啟動(dòng)、停止 和 重啟服務(wù)。
啟動(dòng):service tomcat start
停止:service tomcat stop
重啟:service tomcat restart
Tomcat 配置開機(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
以上是“如何實(shí)現(xiàn)自啟動(dòng)Tomcat服務(wù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。