JAKARTAPROJECT
JAKARTA TIPJSP TIPJSP 질문&답변DATABASE TIPJAVASCRIPT TIPWEBHACKING TIP기타 TIP
자카르타 프로젝트
자카르타 프로젝트
자카르타 프로젝트 팁 게시판 입니다
Installing Tomcat with commons-daemon (jsvc)
GoodBug
이미지 슬라이더 보기

 

Installing Tomcat with commons-daemon (jsvc)

Most installation that I've seen of Tomcat is made with tomcat running as root. This could potentially be a disasters security hole. Most Linux systems only allow the root to listen to port 80...which is why many users of tomcat under Linux run tomcat as root. With jscv, the process will start off as root but later on will change owner to a user of your choice.

 

 

Installation

Create the user to run tomcat under with

useradd tomcat

 

This will create a directory under

 

/home/tomcat

 

Download and install tomcat under /usr/tomcat. This is how my tomcat directory looks like

 

ls -l /home/tomcat
drwxr-xr-x  3 tomcat tomcat  4096 Dec 13 02:51 bin
drwxr-xr-x  6 tomcat tomcat    56 Sep 23 09:42 common
drwxr-xr-x  3 tomcat tomcat  4096 Dec 13 05:18 conf
-rw-r--r--  1 tomcat tomcat 11357 Sep 23 09:44 LICENSE
drwxr-xr-x  2 tomcat tomcat    25 Dec 13 02:51 logs
-rw-r--r--  1 tomcat tomcat   688 Sep 23 09:44 NOTICE
-rw-r--r--  1 tomcat tomcat  6403 Sep 23 09:42 RELEASE-NOTES
-rw-r--r--  1 tomcat tomcat  7006 Sep 23 09:44 RUNNING.txt
drwxr-xr-x  5 tomcat tomcat    44 Sep 23 09:42 server
drwxr-xr-x  4 tomcat tomcat    30 Sep 23 09:42 shared
drwxr-xr-x  2 tomcat tomcat     6 Sep 23 09:42 temp
drwxr-xr-x  3 tomcat tomcat    35 Dec 13 05:17 webapps
drwxr-xr-x  3 tomcat tomcat    21 Dec 13 02:52 work

 

Compile the jscv code by following the instructions on http://tomcat.apache.org/tomcat-5.0-doc/setup.html


 

Run As Service


Tomcat 5.x ship with a tomcat service file which you can use and modify. However, it's written to be used with Java 1.4. To use it with Java 1.5 you need to tweak it some more or use the following file. Please note the items in red. Tomcat user and the JDK path which you must update to fit your system. Also make sure the DAEMON_HOME executable is in the right place.


#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <*******@meritonlinesystems.com>
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between Red Hat Tomcat RPM and Chris Bush scripts

 

TOMCAT_PROG=tomcat
JAVA_HOME='/usr/java/jdk1.5.0_06'
CATALINA_HOME='/home/tomcat/'
DAEMON_HOME=$CATALINA_HOME/bin/jsvc
TMP_DIR=/var/tmp
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

 

# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
 TOMCAT_USER="tomcat"
fi

 

RETVAL=0

 

# start and stop functions
start() {
    echo -n "Starting tomcat: "
    chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
    $DAEMON_HOME \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Djava.io.tmpdir=$TMP_DIR \
    -Djava.awt.headless=true \
    -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 \

    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
    return $RETVAL
}

 

stop() {
    echo -n "Stopping tomcat: "
    PID=`cat /var/run/jsvc.pid`
    kill $PID
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
}

 

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        # Ugly hack
        # We should really make sure tomcat
        # is stopped before leaving stop
        sleep 5
        start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

 

exit $RETVAL

 


Start and Stop

To start tomcat, use (on redhat)

service tomcat start

 

To stop

service tomcat stop

 

from http://waelchatila.com/2005/12/13/1134504717808.html

 

commons의 daemon을 이용해서 일반유저로 톰캣을 80포트로 올리는 법입니다

이전에 jsvc가 이미 make 되어 있어야 합니다

 

2006-01-08 20:39:26
220.70.88.***

 

좋은생각 ^^

10점 (1명)
덧글 0개 | 태그 0개 | 관련글보기
태그입력
쉽표(,)구분으로 한번에 여러 태그를 입력할수 있습니다
이름 비밀번호
자카르타 프로젝트
자카르타 프로젝트 팁 게시판 입니다
! 번호 제목 글쓴이 일자 조회
Hierarchy of the Apache Software Foundation GoodBug 2005-10-14 10,740
Jakarta Project 강좌 게시판입니다 8 GoodBug 2005-04-03 11,613
44 Log4J log4j에서 e.printStackTrace() 메시지를 log에 남기는 방법 1 kaiser 2008-10-22 17,546
43 DBUtils DBUtils에서 Clob 사용하기 3 1 GoodBug 2007-08-28 10,568
42 Spring Spring 설정 파일 로딩 1 GoodBug 2007-07-16 11,252
41 POI POI의 HSLF를 이용하여 PowerPoint 문서를 읽어보자 2 GoodBug 2007-05-28 14,836
40 POI POI의 HWPF를 이용하여 MS WORD문서를 읽어보자 2 GoodBug 2007-05-28 16,757
39 Validator Validator 속성들 1 GoodBug 2007-05-11 10,328
38 dd Commons-Fileupload 1.2 1 2 GoodBug 2007-04-23 15,266
37 Apache Apache2 + Tomcat5.5 + mod_jk 4 바이러스天国 2007-01-29 10,969
36 DBUtils DBUtils에서 number 타입의 컬럼이 int형으로 안넘어올때.. 3 1 GoodBug 2006-06-28 10,678
35 흠흠 위험한 static Logger 필드... 2 1 서연아빠 2006-03-16 10,050
Installing Tomcat with commons-daemon (jsvc) GoodBug 2006-01-08 9,004
33 commons Commons DbUtils 몇가지 예제 3 2 GoodBug 2005-11-17 15,123
32 commons Jakarta Commons Net 에서 FTP 사용시 목록이 안보일 경우 2 GoodBug 2005-11-15 21,698
31 listFiles() 에서 null 을 반환 추적.. 신만두 2008-11-11 11,769
30 commons 목록이 안보일 경우 해결기 I탄 1 2 GoodBug 2005-12-23 15,858
29 POI POI로 엑셀파일 읽을때, Invalid header signature 에러 1 GoodBug 2005-11-12 16,467
28 log4j log4j, JSP에서 원하는 Appender 골라쓰기 1 GoodBug 2005-11-07 13,824
27 commons Commons-Email~ 7 2 GoodBug 2005-10-13 17,786
copyright 2005-2017 by Unicorn