Chinaunix首页 | 论坛 | 博客
  • 博客访问: 175788
  • 博文数量: 159
  • 博客积分: 7007
  • 博客等级: 准将
  • 技术积分: 1750
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-17 15:05
文章分类

全部博文(159)

文章存档

2010年(39)

2009年(106)

2008年(14)

我的朋友

分类: LINUX

2009-06-01 12:44:13

[root@tomcat ~]# cd /opt/tomcat/bin/

[root@tomcat bin]# ls

bootstrap.jar catalina-tasks.xml digest.bat service.bat shutdown.bat startup.sh tomcat-juli.jar tool-wrapper.sh
catalina.bat commons-daemon.jar digest.sh setclasspath.bat shutdown.sh tomcat6.exe tomcat-native.tar.gz version.bat
catalina.sh cpappend.bat jsvc.tar.gz setclasspath.sh startup.bat tomcat6w.exe tool-wrapper.bat version.sh
[root@tomcat bin]# tar zxvf jsvc.tar.gz

[root@tomcat bin]# cd jsvc-src/

[root@tomcat jsvc-src]# chmod +x configure

[root@tomcat jsvc-src]# ./configure --with-java=/opt/java

[root@tomcat jsvc-src]# make

[root@tomcat jsvc-src]# cp /opt/tomcat/bin/jsvc-src/native/Tomcat5.sh /etc/rc.d/init.d/

[root@tomcat jsvc-src]# cd /etc/rc.d/init.d/

[root@tomcat init.d]# chmod +x Tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc0.d/K90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc1.d/K90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc2.d/S90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc3.d/S90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc4.d/S90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc5.d/S90tomcat5.sh

[root@tomcat init.d]# ln -s /etc/init.d/tomcat5.sh /etc/rc6.d/K95tomcat5.sh

[root@tomcat init.d]# more 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

#

#

#

# 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.

##############################################################################

#

# 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:

#

#

#
# 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=/opt/java
CATALINA_HOME=/opt/tomcat
DAEMON_HOME=/opt/tomcat
TOMCAT_USER=root

# for multi instances adapt those lines.

TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/opt/tomcat

CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
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/bin/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/bin/jsvc-src/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac
[root@tomcat init.d]# /etc/rc.d/init.d/Tomcat5.sh start

[root@tomcat init.d]# netstat -tnl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::8009 :::* LISTEN
tcp 0 0 :::8080 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@tomcat init.d]# /etc/rc.d/init.d/Tomcat5.sh stop

[root@tomcat init.d]# netstat -tnl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@tomcat init.d]# useradd tomcatadmin

[root@tomcat init.d]# vi Tomcat5.sh

TOMCAT_USER=tomcatadmin 改为这样
[root@tomcat /]# chown -R tomcatadmin:tomcatadmin /opt/tomcat

[root@tomcat /]# netstat -tnl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@tomcat /]# /etc/rc.d/init.d/Tomcat5.sh start

[root@tomcat /]# netstat -tnl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::8009 :::* LISTEN
tcp 0 0 :::8080 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@tomcat /]# /etc/rc.d/init.d/Tomcat5.sh stop

[root@tomcat /]# netstat -tnl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@tomcat /]# vi /etc/rc.d/init.d/Tomcat5.sh

#!/bin/sh下面加入

#chkconfig: 2345 85 15

#description: 任意内容

[root@tomcat /]# chkconfig --level 345 Tomcat5.sh on

[root@tomcat /]# init 6

阅读(827) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~