文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>tomcat开机自动启动

tomcat开机自动启动

时间:2009-06-01  来源:gamester88


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

#

# <!-- 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=/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

相关阅读 更多 +
排行榜 更多 +
龙珠格斗火柴人

龙珠格斗火柴人

飞行射击 下载
荒野恐龙猎手安卓版

荒野恐龙猎手安卓版

飞行射击 下载
超凡坦克英雄

超凡坦克英雄

飞行射击 下载