블로그 이미지
좋은느낌/원철
이것저것 필요한 것을 모아보렵니다.. 방문해 주셔서 감사합니다..

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

    2009. 6. 11. 17:44 개발/Linux 계열

    톰켓 설치하기

     


    0.미리 설치해야할 것

    JAVA버전이 톰켓에서 지원하는 버전을 설치하여야한다. 보통 기본으로 설치된 자바는 버전이 낮으니 높은 버전의 JAVA를 설치해 보자.

     


    1. 톰켓 다운받기

    tomcat 을 http:/www.apache.org에서 다운 받는다. 이때 우리는 소스 버전과 바이너리 버전을 다운 받을 수 있다. 소스 버전의 경우 ant 등을 설치해서 컴파일해야한다. 바이너리 버전을 다운 받아서 압축을 푼다.


    2.압축풀기

     


    # gzip -dc jakarta-tomcat-5.0.19.tar.gz | tar xvf -

     


    3.톰켓 폴더 옮기기

     


    jakarta-tomcat-5.0.19 디렉토리가 하나 생겼다. 이 디렉토리를 통체로 옮긴다. 옮길 위치는 자신이 설치한 프로그램들이 모여있는곳이 적당하다. (ex: /usr/local/tomcat-5)


    bin 디렉토리에 있는 파일 중 톰켓을 실행 시키는 파일은 startup.sh

    중지 시키는 파일은 shutdown.sh 이다.

    4.톰켓 설정하기

    startup.sh를 수정하자. JAVA의 PATH를 적어넣으면 된다.

    [ns@/usr/local/httpd/tomcat.5/bin] # vi startup.sh

    # -----------------------------------------------------------------------------

    # Start Script for the CATALINA Server

    #

    # $Id: startup.sh,v 1.3 2002/08/04 18:19:43 patrickl Exp $

    # -----------------------------------------------------------------------------


    # ADD PATH

    JAVA_HOME=/usr/j2se

    export JAVA_HOME

    CATALINA_HOME=/usr/local/httpd/tomcat.5

    export CATALINA_HOME 
     


    위 부분을 추가해주자. (참고로 catalina.sh, shutdown.sh도 위와 마찬가지로 수정해주자.)

     


    다시 실행시켜본다.

    [ns@/usr/local/httpd/tomcat/bin] # ./startup.sh

    Using CATALINA_BASE:   /usr/local/httpd/tomcat.5

    Using CATALINA_HOME:   /usr/local/httpd/tomcat.5

    Using CATALINA_TMPDIR: /usr/local/httpd/tomcat.5/temp

    Using JAVA_HOME:       /usr/j2se

     


    인터넷 브라우저를 켜서 한번 확인해본다.

     


    http://homeaddress:8080

     


    ***********************************************
    ***********************************************


    ***********************************************
    ***********************************************

    jakarta-tomcat-connectors 톰켓과 아파치 연동하기

     


    아파치와 톰켓은 8009포트로 통신이 가능하다 이를 이용해서 아파치와 톰켓을 연동하여 사용할 수있다.


    1.jakarta-tomcat-connectors 다운받기

    우선 jk connecter 을 다운 받자 소스로 다운 받아야한다. (참고로 jk가 아니라 jk2 이다.)

    아마 현재 릴리즈 되는 파일의 이름은 분명히 jakarta-tomcat-connectors-jk2-src-current.tar.gz 이것이다.


    2.압축을 푼다.

     


    #gzip -d  jakarta-tomcat-connectors-jk2-src-current.tar.gz

    #tar -xvf jakarta-tomcat-connectors-jk2-src-current.tar

     


    3.컴파일을 한다.

    jakarta-tomcat-connectors-jk2-2.0.4-src 라는 디렉토리가 생성된다.

    커넥터를 컴파일 하기 위해서 /jk/native2디렉토리로 이동한다. 
    # cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/


    설치에 관한 환경 설정을 하는 buildconf.sh를 먼저 실행해 준다.

     


    # ./buildconf.sh

     


    이후 에러가 뜨지 않는다면 configure 를 실행한다.

     


    # ./configure --with-apxs2=/usr/local/httpd/apache/bin/apxs


    --with-apxs2 라는 옵션을 사용해서 아파치의 apxs 의 위치를 알려준다.

     


    이모든 과정을 끝난 이후. make를 한다. 참고로 make install 은 않된다.

     


    4.mod_jk2.so복사하기

    jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache2디렉토리로 이동


    mod_jk2,so파일을 아파치 모듈에 추가

     


    # cp mod_jk2.so /usr/local/httpd/apache/modules/


    5.workers2.properties 복사하기

    /usr/local/httpd/apache/conf 에 복사한다.

     


    mod_jk2.so 모듈은 workers2.properties 파일을 참고로 해서 어떻게 작동해야 할지 결정한다.

    6.톰켓설정하기

    톰켓의 conf폴더에는 jk2.properties파일을 수정한다.


    톰켓 5에는 coyote connector 가 기본적으로 설치되어 있다. coyote connector가 하는 역할은 mod_jk2 의 모듈에서 전달하는 정보를 수신 송신하는 역할을 한다. 이것을 설정하는 파일이 jk2.properties 파일이다.  [ns@/usr/local/httpd/tomcat.5/conf] # vi jk2.properties

    ## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED

    ## WHEN YOU EDIT THE FILE.


    ## COMMENTS WILL BE _LOST_


    ## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.


    # Set the desired handler list

    # handler.list=apr,request,channelJni

    #

    # Override the default port for the socketChannel

    channelSocket.port=8009

    # Default:

    # channelUnix.file=${jkHome}/work/jk2.socket

    # Just to check if the the config  is working

    shm.file=/usr/local/httpd/apache/logs/jk2.shm


    # In order to enable jni use any channelJni directive

    # channelJni.disabled = 0

    # And one of the following directives:


    # apr.jniModeSo=/opt/apache2/modules/mod_jk2.so


    # If set to inprocess the mod_jk2 will Register natives itself

    # This will enable the starting of the Tomcat from mod_jk2

     

    apr.jniModeSo=inprocess 
     

     

     

    7.아파치 설정

    httpd.conf의 적절한 곳에 LoadModule jk2_module modules/mod_jk2.so 이 내용을 적는다.

     

     

    8.workers2.properties파일 수정

    톰켓과 아파치가 연동하는 부분을 설정하는 부분이다. 톰켓과 아파치는 8009번포트를 사용해 서로 통신하게 된다.

    [ns@/usr/local/httpd/apache/conf] # vi workers2.properties

    # Shared memory handling. Needs to be set.

    [shm]

    file=/usr/local/httpd/apache/logs/shm.file

    size=1048576


    # Example socket channel, explicitly set port and host.

    [channel.socket:localhost:8009]

    port=8009

    host=127.0.0.1


    # define the worker

    [ajp13:localhost:8009]

    channel=channel.socket:localhost:8009


    # Announce a \"status\" worker

    [status:status]


    # Uri mapping

    [uri:/jsp-examples/*]

    worker=ajp13:localhost:8009


    [uri:/servlets-examples/*] 
     

    worker=ajp13:localhost:8009


    [uri:/tomcat-docs/*]

    worker=ajp13:localhost:8009


    [uri:/*]

    worker=ajp13:localhost:8009


    [uri:/status/*]

    worker=status:status 
     


    설정한 후에 톰켓, 아파치를 다시 실행한다. 위의 것을 그대로 복사해서 만들어도 된다.

    (아마도 리부팅 후 실행하는 것이 좋을 듯하다.)

    그리고 http://homeaddress/ 를 입력해본다.

    http://homeaddress:8080/ 과 같은 화면이 뜬다면

    posted by 좋은느낌/원철