본문 바로가기

OS의 속삭임/Linux의 외침

[OS][LINUX][tomcat] Tomcat 설치


※ tomcat은 압축만 풀면 설치가 완료 된것이다. 리눅스나 windows나 같다. 하지만 여기서 조금더 깊게 들어 가보겠다.



1. Tomcat 데몬 유저 추가 

shell> useradd -m -r -d /home/tomcat -c "Tomcat Server" -s /bin/bash tomcat


2. 바이너리 설치 

shell> tar xpzf apache-tomcat-6.0.16.tar.gz -C /var/tmp

shell> mv /var/tmp/apache-tomcat-6.0.16 /home/tomcat

shell> ln -s /home/tomcat/apache-tomcat-6.0.16 /home/tomcat/tomcat


shell> cd /home/tomcat/tomcat/bin

shell> ./startup.sh (./catalina.sh start)

shell> ./shutdown.sh (./catalina.sh stop)


shell> vi /etc/profile.d/tomcat.sh

#/etc/profile.d/tomcat.sh

export CATALINA_HOME=/home/tomcat

export PATH=$CATALINA_HOME/bin:.:$PATH


shell> source /etc/profile



3. jar, class 파일 복사

# SetCharacterEncodingFilter.class

- 원본 : $CATALINA_HOME/webapps/jsp-examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.class 

- 대상 : $CATALINA_HOME/common/classes/filters/SetCharacterEncodingFilter.class 

shell> cp  $CATALINA_HOME/webapps/jsp-examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.class $CATALINA_HOME/common/classes/filters/SetCharacterEncodingFilter.class 

 Tomcat 6.X 버전부터는 %CATALINA_HOME%/common 폴더가 존재하지 않는다.


# tools.jar

- 원본 : $JAVA_HOME/lib/tools.jar

- 대상 : $CATALINA_HOME/lib/tools.jar

shell> cp $JAVA_HOME/lib/tools.jar $CATALINA_HOME/lib/tools.jar



# servlet-api.jar

- 원본 : $CATALINA_HOME/lib/servlet-api.jar

- 대상 : $JAVA_HOME/jre/lib/ext/servlet-api.jar

shell> cp $CATALINA_HOME/lib/servlet-api.jar $JAVA_HOME/jre/lib/ext/servlet-api.jar


4. 기본 클래스 로더 추가.

shell> vi $CATALINA_HOME/conf/catalina.properties (수정)

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/classes


common classloader가 검색할 Jar파일이나 class파일이 존재하는 추가적인 경로(path) 지정


5. tomcat 시작 스크립터 

shell> vi tomcat

#!/bin/sh

# Source function library.

. /etc/rc.d/init.d/functions


source /etc/profile

export TOMCAT_HOME=/home/tomcat


# See how we were called.

case "$1" in

start)

echo -n "Starting tomcat EXPERIMENTAL: "

daemon "su - root -c $TOMCAT_HOME/bin/startup.sh"

echo

;;

stop)

echo -n "Shutting down tomcat EXPERIMENTAL: "

daemon "su - root -c $TOMCAT_HOME/bin/shutdown.sh"

echo

;;

restart)

$0 stop

$0 start

;;

*)

echo "Usage: $0 {start|stop|restart}"

exit 1

esac


exit 0