重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
這篇文章主要為大家展示了“如何實(shí)現(xiàn)自啟動(dòng)Tomcat服務(wù)”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“如何實(shí)現(xiàn)自啟動(dòng)Tomcat服務(wù)”這篇文章吧。
創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、成都做網(wǎng)站、香坊網(wǎng)絡(luò)推廣、小程序定制開發(fā)、香坊網(wǎng)絡(luò)營(yíng)銷、香坊企業(yè)策劃、香坊品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供香坊建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
如果我們使用war 包進(jìn)行部署項(xiàng)目的時(shí)候,需要把包放進(jìn)Tomcat的目錄下,為了使我們的服務(wù)能夠在服務(wù)器重啟的時(shí)候自動(dòng)啟動(dòng)起來(lái),我們需要把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)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!