Search Results for 'Tomcat jsvc'


1 posts related to 'Tomcat jsvc'

  1. 2010/04/05 Apache Tomcat 일반계정으로 구동하기
* Apache Tomcat 일반계정으로 구동하기
  - jsvc 이용(Tomcat ver 6.0.18)

Apache Tomcat 웹 사이트에서 Tomcat 5.5 / Tomcat 6.x binary 를 다운로드 받아
압축을 풀어보면 bin 디렉토리 안에 jsvc.tar.gz 파일이 존재한다.
jsvc.tar.gz을 압축풀고 컴파일 한다.

아래는 설치(명령어만) 과정이다.
[root@host ~]# cd /usr/local/tomcat/bin
[root@host ~]# tar zxf jsvc.tar.gz
[root@host ~]# cd jsvc-src
# 실행가능하도록 퍼미션 변경
[root@host ~]# chmod 755 ./configure
# compile전 옵션 설정
[root@host ~]# ./configure --with-java=/usr/local/jdk
# compile
[root@host ~]# make
# daemon file 복사
[root@host ~]# cp native/jsvc $CATALINA_HOME/bin
# daemon 실행 shell script 복사
[root@host ~]# cp native/Tomcat5.sh $CATALINA_HOME/bin
# shell script 환경 설정(path 설정, tomcat user)
[root@host ~]# vi $CATALINA_HOME/bin/Tomcat5.sh
# 기동
[root@host ~]# $CATALINA_HOME/bin/Tomcat5.sh start
# 종료
[root@host ~]# $CATALINA_HOME/bin/Tomcat5.sh stop


아래는 Tomcat5.sh 파일을 수정해 Redhat계열의 init.d에서 돌아가도록 만든 파일이다.
#!/bin/sh
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 80 20
# description: Apache Tomcat on JSVC tool.

# Source function library.
. /etc/rc.d/init.d/functions

##############################################################################
#
#   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)
#
# Adapt the following lines to your configuration


JAVA_HOME=/usr/local/jdk
CATALINA_HOME=/usr/local/tomcat
DAEMON_HOME=/usr/local/tomcat
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=/usr/local/apr/lib"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

PROGNAME=`basename $0`
RETVAL=0

start()
{
    START_COMMAND="\
    $DAEMON_HOME/bin/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 \
    #-verbos \
    # To get a debug of jsvc
    #-debub

    echo -n $"Starting $PROGNAME : "
    daemon $START_COMMAND
    RETVAL=$?
    [ $RETVAL -eq 0 ] && [ -f $PID_FILE ]
    echo
    return $RETVAL
}


stop()
{
    STOP_COMMAND="\
    $DAEMON_HOME/bin/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap"

    echo -n $"Stopping $PROGNAME : "
    killproc jsvc 
    RETVAL=$?
    echo
    return $RETVAL
}

restart()
{
    stop
    start
}


case "$1" in
  start)
    start
    ;;

  stop)
    stop 
    ;;

  status)
    status -p $PID_FILE jsvc
    ;;

  restart)
    restart
    ;;

  *)
    echo "Usage $PROGNAME start/stop"
    exit 1;;
esac

exit $?


2010/04/05 16:31 2010/04/05 16:31