linux下安裝tomcat6

來源:互聯網
上載者:User

安裝tomcat6。
  將tomcat安裝包複製到/usr下。

  cp apache-tomcat-6.0.14.tar /usr/
  cd /usr
  mkdir tomcat6
  tar -zvxf apache-tomcat-6.0.14.tar
  解壓後,就可以啟動了。
  cd /usr/tomcat6/bin
  sh startup.sh
測試
http://127.0.0.1:8080
出現小貓說明成功
附加到系統啟動
#vi /etc/rc.d/rc.local
#/usr/local/tomcat/bin/startup.sh(加到檔案末尾)  Tomcat啟動可以用內建的jsvc來實現(轉):

jsvc本來要從 http://jakarta.apache.org 下載,不過tomcat6 已經自己帶了一個,在apache-tomcat-6.0.13/bin目錄下有一個jsvc.tar.gz包,解壓,編譯:

#tar -xzvf jsvc.tar.gz
#cd jsvc-src
#sh support/buildconf.sh
#./configure --with-java=/usr/java
#make

查看/usr/local/apache-tomcat-6.0.13/bin/jsvc-src/native目錄下有兩個指令碼 Tomcat.sh 和 Tomcat5.sh ,分別用作tomcat5前後版本的啟動和停止tomcat的指令碼。
由於每台機器的配置不盡相同,因此需要修改啟動指令碼的參數。

這裡以tomcat6為例,因此修改Tomcat5.sh。修改後的檔案如下:

#!/bin/sh
##############################################################################
#
#  Copyright 2004 The Apache Software Foundation.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
##############################################################################
#
#chkconfig: 2345 85 15
#description: apache-tomcat.6

#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#              port="80" minProcessors="5" maxProcessors="75"
#              enableLookups="true" redirectPort="8443"
#              acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/usr/java/jdk1.6.0_01
CATALINA_HOME=/usr/local/apache-tomcat-6.0.13
DAEMON_HOME=/usr/local/apache-tomcat-6.0.13/bin
TOMCAT_USER=tomcat

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/apache-tomcat-6.0.13
#CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CATALINA_OPTS=

CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case "$1" in
  start)
    #
    # Start Tomcat
    #
   $DAEMON_HOME/jsvc-src/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile $CATALINA_HOME/logs/catalina.out \
    -errfile '&1' \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    exit $?
    ;;
  stop)
    #
    # Stop Tomcat
    #
   $DAEMON_HOME/jsvc-src/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;
  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac

修改完成後,將Tomcat5.sh拷貝到 /etc/rc.d/init.d/目錄下將命名為tomcat
#cp /usr/local/apache-tomcat-6.0.13/bin/jsvc-src/native/Tomcat5.sh /etc/rc.d/init.d/tomcat

添加進系統服務
#chkconfig --add tomcat
用--list看一下是否系統已有tomcat開機檔案
#ckhconfig --list
即可把tomcat 添加為系統服務自動隨系統啟動了。這個指令碼會在runlevel 2/3/4/5三種模式自動啟動。

系統服務指令碼必須有這下面這兩行
#chkconfig: 2345 85 15 

(註:在運行級2/3/4/5中加入服務,啟動順序85,停止順序15)
#description: apache-tomcat.6

相關文章

聯繫我們

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