linux (centos) 安裝tomcat (用shell指令碼安裝為服務),centostomcat

來源:互聯網
上載者:User

linux (centos) 安裝tomcat (用shell指令碼安裝為服務),centostomcat
1、下載tomcat     從http://tomcat.apache.org/download-70.cgi連結下載linux版本(tar.gz)
2、解壓,上傳及賦許可權     解壓,用WinSCP把解壓的安裝檔案上傳到/home/software/tomcat目錄     並用   chmod -R 755 /home/software/tomcat命令賬許可權。

3、編寫安裝為服務的指令碼並運行     shell指令碼如下:     

#! /bin/sh#shell script takes care of starting and stopping# the glassfish DAS and glassfish instance.## chkconfig: - 64 36# description: Tomcat auto start# /etc/init.d/tomcatd# Tomcat auto-start# Source function library.#. /etc/init.d/functions# source networking configuration.#. /etc/sysconfig/networkRETVAL=0export JRE_HOME=/usr/local/jdk1.7.0export CATALINA_HOME=/home/jinyuan/tomcat/tomcatjinyuan1export CATALINA_BASE=/home/jinyuan/tomcat/tomcatjinyuan1start(){        if [ -f $CATALINA_HOME/bin/startup.sh ];          then            echo $"Starting Tomcat"                $CATALINA_HOME/bin/startup.sh            RETVAL=$?            echo " OK"            return $RETVAL        fi}stop(){        if [ -f $CATALINA_HOME/bin/shutdown.sh ];          then            echo $"Stopping Tomcat"                $CATALINA_HOME/bin/shutdown.sh            RETVAL=$?            sleep 1            ps -fwwu yhjhoo | grep apache-tomcat|grep -v grep | grep -v PID | awk '{print $2}'|xargs kill -9            echo " OK"            # [ $RETVAL -eq 0 ] && rm -f /var/lock/...            return $RETVAL        fi}case "$1" in start)         start        ;; stop)          stop        ;;                                                 restart)         echo $"Restaring Tomcat"         $0 stop         sleep 1         $0 start         ;; *)        echo $"Usage: $0 {start|stop|restart}"        exit 1        ;;esacexit $RETVAL
  命名為tomcatoa(這個名稱就是服務名,後面用命令方式啟動時可用),用winscp把這個指令檔上傳到/etc/init.d/目錄下  並執行以下指令碼:  sudo chmod +x /etc/init.d/tomcatoa

  chkconfig --add tomcatoa

  chkconfig  tomcatoa  on

4、用service tomcatoa start命令啟動服務







      

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.