我是靠谱客的博主 幽默酸奶,最近开发中收集的这篇文章主要介绍配置service启动以及关闭tomcat服务,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

配置用service 启动tomcat

在用RedHat最为服务器的操作系统的时,一般情况下用service启动及其关闭服务,为了让我们自己用着习惯,所以就配置了用service 启动和关闭tomcat服务,当然在这里我是用配置tomcat环境,进行配置该项服务的,如果您要是配置该项服务,请您自己动手配置一下tomcat服务,在这里就略过

1创建tomcat用户

  #useradd  -s  /sbin/nologin  tomcat

2 进入/usr/local/tomcat/bin目录下面

#cd /usr/local/tomcat/bin

3 解压jsvc.tar.gz 文件并进入该目录

#tar xvf  jsvc.tar.gz 

#cd  jsvc-src

#bash  configure

 #make

在该目录下面生成jsvc,并把该文件复制到上一级目录中去

#cp  jsvc ../

4并把/usr/local/tomcat 的用户及其组全部修改为tomcat

#chown  -R tomcat.tomcat /usr/local/tomcat

 #cd  native

 5 查找脚本文件Tomcat5.sh 并把该文件复制到/etc/init.d/ ,并改名为tomcat

    #cp Tomcat5.sh  /etc/init.d/tomcat

  修改权限

 #chmod  755 –R /etc/init.d/tomcat

 

6修改/etc/init.d/tomcat

注:红色的部分为修改部分

 

#!/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:
#
#    <!-- 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)
#description:this is tomcat start script
#chkconfig: 345 88 14
#

# Adapt the following lines to your configuration
JAVA_HOME=/usr/java
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=/usr/local/tomcat/bin
TOMCAT_USER=tomcat


# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/usr/local/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/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
    -stop
    -pidfile $PID_FILE
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac

 

7 把tomcat添加到自动启动列队中

     #chkconfig  --add  tomcat

     #chkconfig  tomcat  on

 

8 验证service 启动和关闭tomcat服务,验证的时查看对应的端口号

    #service tomcat start

    #netstat  -tunlp

#service tomcat stop

#netstat  -tunlp

#service tomcat start

9在浏览器中输入

 http://localhost

转载于:https://my.oschina.net/u/3054960/blog/842061

最后

以上就是幽默酸奶为你收集整理的配置service启动以及关闭tomcat服务的全部内容,希望文章能够帮你解决配置service启动以及关闭tomcat服务所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部