|
ÀÛ¼ºÀÏ : 11-11-17 17:24
mod_jk¸¦ ÀÌ¿ëÇÑ Apache2 + Tomcat5.5 ¿¬µ¿ ¹× °¡»óÈ£½ºÆÃ
|
|
Á¶È¸ : 57,158
|
|
³»¿ë¿¡ µé¾î°¡±â¿¡ ¾Õ¼ Âü°í »çÀÌÆ® : Configuring Tomcat5 and Apache2 with Virtual Hosts using mod_jk
Apache2¿Í Tomcat5.5µîÀÇ ¼³Ä¡´Â ÀÌ°÷¿¡¼ ´Ù·çÁö ¾Ê½À´Ï´Ù. ¾ÆÆÄÄ¡¿Í ÅèĹ °¢°¢ ¾î´ÀÁ¤µµ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù¸é ÀÌ ¹®¼ÀÇ ³»¿ëÀº ¾î·ÆÁö ¾Ê½À´Ï´Ù. °³Àθ¶´Ù ¼³Á¤µéÀÌ Á¶±Ý¾¿ ´Ù¸£¹Ç·Î ¹«ÀÛÁ¤ ¶È°°ÀÌ µû¶óÇϱ⠺¸´Ù´Â °æ·Î¿¡ ÁÖÀÇÇϸç ÀÚ½ÅÀÇ ¼³Á¤¿¡ ¸Â°Ô Àû¿ëÇØ¾ß ÇÕ´Ï´Ù.
ÅèĹ°ú ¿¬µ¿¿¡ ÇÊ¿äÇÑ mod_jk(mod_jk2°¡ ¾Æ´Ô)¶ó´Â ¾ÆÆÄÄ¡¿ë ¸ðµâÀ» ¼³Ä¡ÇÕ´Ï´Ù. ¸ðµâÀ» ¼³Ä¡ÇÏ´Â ¹æ¹ýÀº ´Ù¾çÇϹǷΠ¾ÆÆÄÄ¡¿ë ¸ðµâÀ» ¼³Ä¡ÇÏ°í ·ÎµåÇÏ´Â ¹æ¹ýÀº µû·Î ´Ù·çÁö ¾Ê°Ú½À´Ï´Ù. ¿ìºÐÅõ¶ó¸é apt·Î °£´ÜÈ÷ ¼³Ä¡ÇÒ ¼ö ÀÖ½À´Ï´Ù.
ÀÌ ¹®¼¿¡¼ ¾ÆÆÄÄ¡¼³Á¤ÆÄÀÏ, ÅèĹ, mod_jkÀÇ °æ·Î´Â ¾Æ·¡¿Í °°½À´Ï´Ù. ¾ÆÆÄÄ¡¼³Á¤ÆÄÀÏ : /etc/apache2/ ÅèĹ : /usr/lib/apache-tomcat mod_jk : /usr/lib/apache2/modules/mod_jk.so
workers.properties ÆÄÀÏ ¸¸µé±â workers.properties ¶ó´Â ÆÄÀÏÀ» Àû´çÇÑ °÷¿¡ »ý¼ºÇÏ°í ¾Æ·¡¿Í °°Àº Äڵ带 ³Ö½À´Ï´Ù. ÀÌ°÷¿¡¼´Â /etc/apache2/workers.properties ·Î »ý¼ºÇß½À´Ï´Ù.
#¾Æ·¡ÀÇ µÎ ¼³Á¤ÀÇ °æ·Î´Â Àڽſ¡ ¸Â°Ô ¼öÁ¤ÇÕ´Ï´Ù. workers.tomcat_home=/usr/lib/apache-tomcat workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
#¾Æ·¡ ¹Ýº¹µÇ´Â worker1 ´ë½Å ´Ù¸¥ À̸§µµ »ó°ü¾ø½À´Ï´Ù. worker.list=worker1
worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.lbfactor=1
worker.loadbalancer.type=lb worker.loadbalancer.balanced_workers=worker1
worker.inprocess.type=jni worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar worker.inprocess.cmd_line=start worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps) i386$(ps)classic$(ps)libjvm.so
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
ÅèĹÀÇ server.xml ¼öÁ¤ ÅèĹ/conf/server.xml ¿¡ ¾Æ·¡ÀÇ Äڵ带 Ãß°¡ÇÕ´Ï´Ù. Server ÅÂ±× ¹Ù·Î ¾Æ·¡ÂÊ¿¡ Listener űװ¡ ÀûÈù°÷¿¡ Ãß°¡ÇÏ¸é µË´Ï´Ù. modjk¿Í workersConfigÀÇ °æ·Î¿¡ ÁÖÀÇÇؼ Àڽſ¡ ¸Â°Ô ¼öÁ¤ÇÕ´Ï´Ù.
<Listener className="org.apache.jk.config.ApacheConfig" modJk="/usr/lib/apache2/modules/mod_jk.so" workersConfig="/etc/apache2/workers.properties" />
ÅèĹÀ» Àç½ÃÀÛ ÇÕ´Ï´Ù. $ cd /usr/lib/apache-tomcat/bin $ ./shutdown.sh $ ./startup.sh
¿¡·¯¾øÀÌ Àç½ÃÀÛ µÇ¸é ¾Æ·¡¿Í °°Àº ÆÄÀÏÀÌ »ý¼ºµË´Ï´Ù. /usr/lib/apache-tomcat/conf/auto/mod_jk.conf
apache2.conf ¼öÁ¤ /etc/apache2/apache2.conf ¼³Á¤ ÆÄÀÏ¿¡ ¾Æ·¡ÀÇ Äڵ带 Ãß°¡ÇÕ´Ï´Ù. Ç×»ó °æ·Î¿¡ ½ÅÁßÇϼ¼¿ä.
Include /usr/lib/apache-tomcat/conf/auto/mod_jk.conf # Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T"
# Globally deny access to the WEB-INF directory <LocationMatch '.*WEB-INF.*'> AllowOverride None deny from all </LocationMatch>
À§ÀÇ Äڵ忡¼ LocationMatch '.*WEB-INF.*' ºÎºÐÀÌ Áß¿äÇÕ´Ï´Ù. jsp¿¡¼ WEB-INFÀÇ ³»¿ëÀº ¿©·¯°¡Áö ¼³Á¤À» °®°íÀÖ´Â Áß¿äÇÑ ºÎºÐÀ̹ǷΠº¼ ¼ö ¾øµµ·Ï ¸·¾Æ³õ½À´Ï´Ù.
VirtualHost ¼³Á¤ ÆÄÀÏ ¼öÁ¤ ÀÌ ¹®¼´Â /etc/apache2/sites-available/default ÆÄÀÏ¿¡ VirtualHost°¡ ¼³Á¤µÇ¾î ÀÖ½À´Ï´Ù. ÆÄÀÏÀ» ¿¾îº¸¸é <VirtualHost *> ºÎºÐÀÌ ÀÖ½À´Ï´Ù.
ÀÌ ºÎºÐÀÇ DocumentRoot¸¦ ¼öÁ¤ÇÕ´Ï´Ù.(°æ·ÎÁÖÀÇ) DocumentRoot /usr/lib/apache-tomcat/webapps/ROOT
±×¸®°í ¾Æ·¡ÀÇ Äڵ带 VirtualHost ű׻çÀÌ¿¡ Ãß°¡ÇØÁÝ´Ï´Ù.(worker1¿¡ ÁÖÀÇ) JkMount /*.jsp worker1
JkMount´Â ÆÐÅÏ¿¡ ÇØ´çÇÏ´Â ÆÄÀÏ ¶Ç´Â µð·ºÅ丮¸¦ ÅèĹÀÌ Ã³¸®Çϵµ·Ï ÇÏ´Â ¼³Á¤ÀÔ´Ï´Ù.
ÆÄÀÏÀ» ÀúÀåÇÏ°í ¾ÆÆÄÄ¡¸¦ Àç½ÃÀÛ ÇÕ´Ï´Ù. ºê¶ó¿ìÀú¿¡¼ http://127.0.0.1·Î Á¢¼ÓÇßÀ»¶§ ÅèĹ ÆäÀÌÁö°¡ º¸ÀÌ¸é ¿¬µ¿µÈ °ÍÀÔ´Ï´Ù.
ÅèĹÀÇ context ¹®Á¦Á¡ ÅèĹÀÇ context°¡ ¹®Á¦°¡ µÉ ¼ö ÀÖ½À´Ï´Ù. ÄÁÅؽºÆ®ÀÇ °æ·Î´Â DocumentRootÀÇ ÇÏÀ§µð·ºÅ丮ÀÎ °ÍÀÌ ¾Æ´Ï±â ¶§¹®ÀÔ´Ï´Ù. ¾ÆÆÄÄ¡ÀÇ Alias ¼³Á¤À» ÅëÇØ ¹®Á¦¸¦ ÇØ°á ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÅèĹÀÇ adminÀ» ¿¹·Î µé¸é ¾Æ·¡¿Í °°½À´Ï´Ù.
Alias /admin/ "/opt/tomcat/server/webapps/admin/"
JkMount /admin worker1 JkMount /admin/* worker1
°¡»óÈ£½ºÆà ¾ÆÆÄÄ¡, ÅèĹ °¢°¢ÀÇ °¡»óÈ£½ºÆà ¼³Á¤¿¡ ´ëÇؼ ÀÚ¼¼È÷ ´Ù·çÁö´Â ¾Ê°Ú½À´Ï´Ù. ¾ÆÆÄÄ¡, ÅèĹ µÎ°³ÀÇ °¡»óÈ£½ºÆà ¼³Á¤ÀÌ ÀÏÄ¡ÇØ¾ß ¿¬µ¿¿¡ ¹®Á¦°¡ ¾ø½À´Ï´Ù.
¾ÆÆÄÄ¡ÀÇ °¡»óÈ£½ºÆà <VirtualHost test.ani> DocumentRoot /var/www/test JkMount /*.jsp worker1 </VirtualHost>
ÅèĹÀÇ °¡»óÈ£½ºÆÃ(server.xml) <Host appBase="/var/www/test" name="test.com"> <Context path="" docBase="" debug="0" reloadable="true"/> </Host>
|
|
|
|
|