Linux(CentOS)下,下載安裝Tomcat並配置__Linux

來源:互聯網
上載者:User

1、下載並解壓

從官方網址(http://tomcat.apache.org/)上,選擇合適的版本並下載(我選擇的是:apache-tomcat-8.0.9.tar.gz)。

# mkdir tomcat-src && cd tomcat-src# wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.17/bin/apache-tomcat-8.0.17.tar.gz# tar xzf apache-tomcat-8.0.17.tar.gz

2、啟動或關閉

進入Tomcat的bin目錄下,使用它提供的指令碼命令(startup.sh/shutdown.sh),即可啟動或關閉。
啟動後,可以使用瀏覽器開啟頁面(http://host:8080),如果出現Tomcat的預設頁面,即為成功。

3、添加系統服務

使用命令“# vi /etc/init.d/tomcat”,開啟編輯器,輸入如下內容:

#!/bin/bash# chkconfig: 2345 85 15# vi /etc/init.d/tomcat# init script for tomcat precesses# gaojs@hz.cnTOMCAT_HOME="/home/tomcat-8.0.17"case "$1" instart)        if [ -f $TOMCAT_HOME/bin/startup.sh ];          then            echo $"Starting Tomcat"            su - root -c "$TOMCAT_HOME/bin/startup.sh"        fi        ;;stop)        if [ -f $TOMCAT_HOME/bin/shutdown.sh ];          then            echo $"Stopping Tomcat"            su - root -c "$TOMCAT_HOME/bin/shutdown.sh"        fi        ;;*)        echo $"Usage: $0 {start|stop}"        exit 1        ;;esacexit 0
儲存退出後,再使用下面的命令,使其可執行;然後,添加配置並查看。
可用chkconfig修改其值,也可用ntsysv工具改變是否自啟動。
# chmod +x /etc/init.d/tomcat# chkconfig --add tomcat# chkconfig tomcat on/off  # chkconfig --list tomcat tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.