免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1278 | 回复: 0
打印 上一主题 下一主题

tomcat开机自动启动 [复制链接]

论坛徽章:
5
寅虎
日期:2015-01-20 09:16:52亥猪
日期:2015-01-21 14:43:44IT运维版块每日发帖之星
日期:2015-12-17 06:20:00每日论坛发贴之星
日期:2015-12-17 06:20:00每周论坛发贴之星
日期:2015-12-20 22:22:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-01 12:44 |只看该作者 |倒序浏览

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


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/71666/showart_1951141.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP