TOMCAT/APACHE
2010.11.26 / 17:23

[LINUX] Apache 2.2 + mod jk 1.2 + Tomcat 5.x ¿¬µ¿ - Window - mod_jk ´Ù¿î·Îµå

¼Õ±â
Ãßõ ¼ö 248
Á¦¸ñ¾øÀ½

[LINUX] Apache 2.2 + mod jk 1.2 + Tomcat 5.x ¿¬µ¿ - Window

¾ÆÆÄÄ¡ ¼³Ä¡ ¿©ºÎ È®ÀÎ

 rpm -qa | grep httpd

 Çؼ­ ¼³Ä¡ ¿©ºÎ¸¦ È®ÀÎ ÇÑ´Ù. fedora core 5 À̻󿡼­´Â ÆÐÅ°Áö¸¦ ÇÁ·Î±×·¥-->Add/Remove Software ¿¡¼­

Á÷Á¢ »èÁ¦ Ãß°¡ ÇÒ¼ö ÀÖ´Ù.

 

JDK ¼³Ä¡

 

 

 1-1. JDK ´Ù¿î·Îµå 

       - http://java.sun.com ¿¡ ¹æ¹®Çؼ­ ¸®´ª½º¿ë JDK¸¦ ´Ù¿î·Îµå ¹Þ´Â´Ù.

       - self-extracting file ¼±ÅÃ, ÆÄÀϸí jdk-6-linux-i586.bin (ÇöÀç ÃֽŠ¹öÀüÀº 1.6 ¹öÀüÀÔ´Ï´Ù.)

       - Âü°í) tomcat 5.5 ¹öÀü¿¡¼­´Â J2SE 5.0 ÀÌ»ó ¹öÀü¿¡¼­ µ¿ÀÛÇÔ.

     

 

 1-2. ´Ù¿î·Îµå ¹ÞÀº ÆÄÀÏÀ» ¸®´ª½ºÀÇ ¾Ë¸ÂÀº Æú´õ¿¡ ¾÷·ÎµåÇÑ´Ù.


 1-3. ´ÙÀ½ ¸í·ÉÀ» »ç¿ëÇؼ­ bin ÆÄÀÏÀ» ½ÇÇà °¡´ÉÇϵµ·Ï º¯°æÇÑ´Ù.
       $ chmod 555 jdk-6-linux-i586.bin

 

 1-4. bin ÆÄÀÏÀ» ½ÇÇàÇÑ´Ù.
       $ ./jdk-6-linux-i586.bin

 

 1-5. ½ÇÇàÇÏ¸é ¶óÀ̼¾½º¿¡ ´ëÇÑ ³»¿ëÀ» ¹°¾îº¸´Âµ¥ yes ¸¦ ÀÔ·ÂÇÑ´Ù.


 1-6. ¼³Ä¡°¡ ÀÚµ¿À¸·Î µÈ´Ù.

       º¸Åë /use/local Æú´õ¿¡¼­ bin ÆÄÀÏÀ» ½ÇÇàÇϸé /usr/local/jdk1.6.0 Æú´õ¿¡ ¼³Ä¡µË´Ï´Ù.

 

 1-7. ¸µÅ©¸¦ °É¾î Ç¥±âÇϱ⠽±°Ô ÇÑ´Ù.

       # ln -s j2sdk jdk1.6.0

 

 

ÅèĹÀÇ ¼³Ä¡

 

  2-1. TOMCAT ´Ù¿î·Îµå 

        - http://tomcat.apache.org ¿¡ ¹æ¹®Çؼ­ tar.gzÀÇ ÅèĹ ¹ÙÀ̳ʸ® ¹èÆ÷ÆÇÀ» ´Ù¿î·Îµå ¹Þ´Â´Ù.

        - Core ¸¦ ¹Þ´Â´Ù. ÆÄÀϸíÀº apache-tomcat-5.5.20.tar.gz ÀÌ´Ù.

        - http://ftp.kaist.ac.kr/pub/Apache/tomcat/tomcat-5/v5.5.20/bin/apache-tomcat-5.5.20.tar.gz


  2-2. ´Ù¿î·Îµå ¹ÞÀº ÆÄÀÏÀ» ¸®´ª½ºÀÇ ¾Ë¸ÂÀº Æú´õ¿¡ ¾÷·ÎµåÇÑ´Ù.


  2-3. ¾ÐÃà ÆÄÀÏÀ» /usr/local Æú´õ¿¡ º¹»çÇÑ´Ù.


  2-4. ¾ÐÃàÀ» Ǭ´Ù.
        $ tar xvzf apache-tomcat-5.5.20.tar.gz

   
  2-5. tomcat À¸·Î ¸µÅ©¸¦ °É¾î ³õ´Â´Ù.

        - /usr/local/apache-tomcat-5.5.20 Æú´õ°¡ »ý±ä´Ù.

        # ln -s apache-tomcat-5.5.20 tomcat

      

  2-6. ȯ°æº¯¼ö¿¡ µî·Ï

        - ÅèĹÀ» ½ÇÇàÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ µÎ °³ÀÇ È¯°æ º¯¼ö¸¦ ¸ÕÀú ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù.

 

        # export JAVA_HOME=/usr/local/j2sdk

        # export CATALINA_HOME=/usr/local/tomcat

 

        - /etc/profile ¿¡µµ ´ÙÀ½°ú °°ÀÌ µî·ÏÇÑ´Ù.

 

       JAVA_HOME=/usr/local/j2sdk
       CATALINA_HOME=/usr/local/tomcat

 

       export JAVA_HOME CATALINA_HOME

 

 

TOMCAT ½ÇÇà

 

  3-1. ÅèÄÏ ½ÇÇà 

        # /usr/local/apache-tomcat-5.5.20/bin/catalina.sh start

 

  3-2. »ç¿ëÇϱâ Æí¸®ÇÏ°Ô ¸µÅ©¸¦ °É¾î ³õ´Â´Ù.

        # ln -s /usr/local/apache-tomcat-5.5.20/bin/catalina.sh /etc/init.d/tomcat

 

  3-3. Á¤»óµ¿ÀÛÇÏ´ÂÁö È®ÀÎÇÑ´Ù.

        - http://test.com:8080

 

 

Âü°í)

The file $CATALINA_HOME/bin/jsvc/native/tomcat.sh can be used as a template for starting Tomcat automatically at boot time from /etc/init.d. The file is currently setup for running Tomcat 4.1.x, so it is necessary to edit it and change the classname from BootstrapService to Bootstrap.

 

/usr/local/apache-tomcat-5.5.20/bin ¿¡¼­ jsvc.tar.gz ÆÄÀÏÀ» ¾ÐÃâÇØÁ¦ ÇÏ°í ./jsvc-src/native/tomcat5.sh ¸¦ »ç¿ëÇÑ´Ù.

 

Note that the Commons-Daemon JAR file must be on your runtime classpath to run Tomcat in this manner. The Commons-Daemon JAR file is in the Class-Path entry of the bootstrap.jar manifest, but if you get a ClassNotFoundException or a NoClassDefFoundError for a Commons-Daemon class, add the Commons-Daemon JAR to the -cp argument when launching jsvc.

 

 

mod jk 1.2 »ý¼º (¼Ò½º ¹öÀü)

 

  4-1. JK ´Ù¿î·Îµå

        - http://tomcat.apache.org/download-connectors.cgi »çÀÌÆ®¿¡¼­ JK 1.2 ¼Ò½º ¹öÀüÀ» ´Ù¿î·Îµå ¹Þ´Â´Ù.

        - http://apache.edgescape.com/tomcat/tomcat-connectors/jk/source/jk-1.2.20/tomcat-connectors-1.2.20-src.tar.gz

        - ¾ÆÆÄÄ¡´Â ´õÀÌ»ó mod jk2¸¦ °ø½ÄÀûÀ¸·Î Áö¿øÇÏÁö ¾Ê´Â´Ù.
        - ¾Æ·¡¿Í °°Àº ¼ø¼­·Î ¼³Ä¡ÇÑ´Ù.

 

        $ tar xvzf tomcat-connectors-1.2.19-src.tar.gz
        $ cd tomcat-connectors-1.2.19-src
        $ cd native
        $ ./configure --with-apxs=/usr/local/apache/bin/apxs
        $ make 2> make_error.txt | tee make_stdout.txt

        $ make install

        or 
       $ cp ./apache-2.0/mod_jk.so /usr/local/apache2.2/modules

 

        - RPMÀ¸·Î ¾ÆÆÄÄ¡¸¦ »ý¼ºÇßÀ¸¸é, apxs ÆÄÀÏÀÌ ¾ø´Ù.

        - ÀÌ·² °æ¿ì httpd-devel ÆÐÅ°Áö¸¦ ¼³Ä¡Çϸé /usr/sbin/apxs °¡ »ý¼ºµÈ´Ù.

 

        # yum install httpd-devel

 

       ./configure --with-apxs=/usr/sbin/apxs

 

        Âü°í) ÄÄÆÄÀϽà ´ÙÀ½°ú °°ÀÌ ¸í·ÉÀ» ³»¸®¸é ÄÄÆÄÀÏÁß ¹®Á¦ ¹ß»ý½Ã È®ÀÎÀÌ ¿ëÀÌÇÏ´Ù.

        $ make 2> make_error.txt | tee make_stdout.txt

        

 

Apache À¥ ¼­¹ö¿Í Tomcat 5.x ¿¬µ¿

 

JK 1.2¸¦ »ç¿ëÇÏ¿© Tomcat 5.x ¹öÀü°ú ¿¬µ¿ÇÒ ¼ö ÀÖ´Ù.

  5-1. worker.properties ÆÄÀÏÀÛ¼º

 

##################### /etc/httpd/conf/worker.properties #####################

# »ç¿ëÇÒ worker ¸ñ·ÏÀ» ÁöÁ¤ÇÑ´Ù. ¾Æ·¡´Â local worker¸¸ ÁöÁ¤ÇÏ¿´À¸¸ç, ¿©·¯ °³¸¦ ÁöÁ¤ÇØ¾ß ÇÒ °æ¿ì ÄÞ¸¶·Î ±¸ºÐ
worker.list=worker1

 

# local worker¿¡ ´ëÇÑ ¼³Á¤: ÅèĹ 5.x´Â ajp13À» ±âº»ÀûÀ¸·Î Á¦°øÇÑ´Ù.
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

 

 

  5-2. tomcat.conf ÆÄÀÏÀ» ÀÛ¼º

        - httpd.conf ÆÄÀÏÀÌ ·ÎµåµÇ¸é¼­ ÇÔ²² ·ÎµåµÉ ¼ö ÀÖµµ·Ï ÇÑ´Ù.

 

##################### /etc/httpd/conf/httpd.conf #####################

#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf 

 

# ±âº» À¸·Î Ãß°¡ µÇ¾î ÀÖ´Ù µÎ¹ø »ç¿ë ÇÏ¸é ¿¡·¯ ³ª»ï Ãß°¡ ÇÒÇÇ¿ä ¾øÀ½

Âü°í)ServerRoot "/etc/httpd" <-- ¾ÆÆÄÄ¡°¡ ¼³Ä¡µÈ ±âº» À§Ä¡

       ServerName localhost <-- È£½ºÆ® Á¤º¸

       DocumentRoot "/web/webkores/webapp" <-- º¯°æ

       --> DocumentRoot "/var/www/html" <--±âº»

       <Directory "/web/webkores/webapp">

        ~~~~

       </Directory>

      --> ±âº»

       <Directory "/var/www/html">

        ~~~~

       </Directory>

   À̹ÌÁö¸¦ À§ÇØ Ãß°¡ ÇÑ´Ù.<-Ãß°¡ ¾ÊÇصµ µÇ´ÂÁö È®ÀÎ ÇغÁ¾ßµÇ´Âµù ¤»

  Alias /resources/ "/web/webkores/webapp/resources/"

   <Directory "/web/webkores/webapp/resources">

     Options Indeses MultiViews 

     AllowOverride None

     Order allow,deny

     Allow from all

</Directory>

 

##################### /etc/httpd/conf.d/tomcat.conf  #####################

# tomcat ¿¬µ¿ ¸ðµâÀÎ mod_jk¸¦ ·Îµù
LoadModule    jk_module  modules/mod_jk.so


# worker Á¤º¸°¡ ¼³Á¤µÈ ÆÄÀÏÀÇ °æ·Î ÁöÁ¤
JkWorkersFile   /etc/httpd/conf/worker.properties

JkLogFile       /etc/httpd/logs/mod_jk.log
JkLogLevel      error
JkLogStampFormat        "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat      "%w %V %T"

 

# ¾î¶² ¿äûÀ» ÅèĹÀ¸·Î º¸³¾ Áö ÁöÁ¤ÇÑ´Ù.
JkMount         /*.jsp worker1
JkMount         /servlet/* worker1
JkMount         /jsp-examples/* worker1
JkMount         /servlets-examples* worker1

 

  5-3. ¿¬µ¿Å×½ºÆ®

        - http://test.com/index.jsp , http://test.com:8080/index.jsp ÀÇ °á°ú°¡ °°ÀºÁö È®ÀÎÇÑ´Ù.

        - http://test.com/jsp-examples/ , http://test.com/servlets-examples/ 

          µð·ºÅ͸®°¡ Á¤»óÀûÀ¸·Î º¸ÀÌ°í ³»ºÎÀÇ JSP ÆÄÀÏ ¶Ç´Â ¼­ºí¸´ µéÀÌ Á¤»óÀûÀ¸·Î ½ÇÇàµÇ´ÂÁö È®ÀÎÇÑ´Ù.

 

 

  5-4. µ¥¸ó½ÇÇà¼ø¼­

         - tomcat ÀÌ ½ÇÇàµÈ ÀÌÈÄ¿¡ httpd °¡ ½ÇÇàÀÌ µÇ¾î¾ß ÇÑ´Ù.

         -/ÅèÄÏ È¨/bin/catalina.sh ÇÏ¸é ½ÃÀÛ µÈ´Ù ÀÏÄÉ Çϸé ÅèÄÏÀÌ ¿Ã¶ó °¡´Â°ÍÀ» º¼¼ö ÀÖ´Ù

         -/ÅèÄÏ È¨/bin/startup.sh ÇÏ¸é ±âº»¸¸ ¶ß»ï

         - /etc/rc.d/init.d/httpd start <== Çؼ­ ¾ÆÆÄÄ¡ ½ÇÇà

         - rc.local ¿¡ tomcat ÀÌ ¼­¹ö½ÇÇà½Ã ¿Ã¶ó¿Ã ¼ö ÀÖµµ·Ï µî·Ï½ÃÄÑ ³õ´Â´Ù.

 

 

ÀÌ¿Í °ü·ÃµÈ º¸´Ù ÀÚ¼¼ÇÑ ³»¿ëÀº http://tomcat.apache.org/connectors-doc/howto/workers.htmlÀ» Âü°íÇϱ⠹ٶõ´Ù.

 

 

==>¿¬µ¿ÈÄ ÇÑ±Û ±úÁö¸é

 ÅèÄÏÀÇ server.xml ÆÄÀÏÀÇ

  connector port="8009"  ¿¡ URIEncoding="euc-kr" À» Ãß°¡ ÇØÁØ´Ù.

 

 

 

 

Âü°í URL

 

JDK ¼³Ä¡ : http://cafe.naver.com/okjsp.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=109

JK ¼³Ä¡ : http://javacan.madvirus.net/