#title Apache2¿Í Tomcat5 ¿¬µ¿Çϱâ
'''Apache2¿Í Tomcat5 ¿¬µ¿Çϱâ'''
[[TableOfContents]]
ÀÛ¼ºÀÚ : ¹Ú»óÇö(ºê·çÆæ½Ã·´)
2006³â 7¿ù 9ÀÏ ÀÏ¿äÀÏ ¿ÀÀü 5½ÃÁò ÀÛ¼ºÀ» ½ÃÀÛÇÏ¿´½À´Ï´Ù. ±âÈÄ´Â.. Á¦ÁÖµµ·Î ÅÂdzÀÌ ºÏ»óÁßÀ̶ó°í ÇÕ´Ï´Ù.
= ¼·Ð =
Àú´Â »çÁ¤»ó PHP¿Í JSP ¸¦ ¸ðµÎ ó¸®ÇØÁÙ ÇÊ¿ä°¡ ÀÖ¾ú±â ¶§¹®¿¡ Apache2/Tomcat5 ¿¬µ¿ ¸ðµ¨À» ¼±ÅÃÇß½À´Ï´Ù.
°¢ÀÚ Ã³ÇÑ È¯°æ¿¡ µû¶ó¼ ÀÌ ¸ðµ¨ÀÌ ÃÖ¼±ÀÌ ¾Æ´Ò ¼öµµ ÀÖ½À´Ï´Ù. Tomcat5 ÀÇ standalone ¸ðµåµµ °í·ÁÇØÁֽñ⠹ٶø´Ï´Ù. ^^
¿¬µ¿½Ã »ç¿ëµÇ´Â connector ¿¡´Â mod_jserv, JK, !JK2, mod_webapp or mod_proxy µîÀÌ ÀÖ½À´Ï´Ù.
ÀÚ¼¼ÇÑ ³»¸·Àº ¾ËÁö´Â ¸øÇÏÁö¸¸ jserv ¿Í mod_webapp ´Â ¿À·¡ÀüºÎÅÍ ¿Ü¸é¹Þ¾Æ¿Â °Í °°°í
!JK2 ´Â °³¹ßÀÚµéÀÇ Èï¹Ì ºÎÁ·À» ÀÌÀ¯·Î °³¹ßÀÌ ÁߴܵǾú½À´Ï´Ù.
µû¶ó¼ JK ¿Í mod_proxy °¡ ³²´Â µ¥.. Apache2.2 ºÎÅÍ´Â mod_proxy_ajp ¸ðµâÀÌ Á¦°øµË´Ï´Ù.
±¹³»¿¡¼´Â ÇØ´ç ¸ðµâÀ» ÀÌ¿ëÇÑ ¿¬µ¿ »ç·Ê¸¦ ãÀ» ¼ö ¾ø¾î¼ µµÀüÇغ¸¾Ò½À´Ï´Ù.
¿¬µ¿½Ã Å×½ºÆ®µÈ ȯ°æÀº ´ÙÀ½°ú °°½À´Ï´Ù.
||OS || Fedora core 5 ||
||Apache2.2 || httpd-2.2.2-1.0 ||
||Tomcat5.5 || tomcat5-5.5.15-1jpp_6fc ||
||Java || jdk 1.5.0_07 ||
¸®´ª½º¿¡ ÀÔ¹®ÇÑÁö ¾ó¸¶ ¾ÈµÇ¾î¼ !FC5 ¿ÜÀÇ È¯°æ¿¡ ´ëÇؼ´Â Àß ¾ËÁö ¸øÇϱ⠶§¹®¿¡
Å×½ºÆ®¿¡ »ç¿ëµÈ ¼³Ä¡ ¹æ¹ýÀÌ Á¦°øµÇÁö ¾Ê°Å³ª ÀûÀýÇÏÁö ¾ÊÀ» ¼ö ÀÖÀ¸¸ç ¾ð±ÞµÈ °æ·ÎµîÀÌ ´Ù¸¦ ¼ö ÀÖ½À´Ï´Ù.
find / -name {´ë»ó} ȤÀº which {´ë»ó} µîÀ¸·Î ÀûÀýÇÑ °æ·Î¸¦ È®ÀÎÇϽñ⠹ٶø´Ï´Ù.
= Apache 2.2 =
* yum À» ÀÌ¿ëÇؼ °ü·Ã rpm ÆÐÅ°ÁöµéÀ» ¼³Ä¡ÇÕ´Ï´Ù.
{{{
# yum -y install httpd\*
}}}
* httpd.conf ÆÄÀÏÀ» ¿¾î¼ ´ÙÀ½¿¡ ¾ð±ÞµÈ ±¸¹®µéÀ» ã¾Æ¼ ¼öÁ¤ÇØÁÝ´Ï´Ù.
°¢ ¹®±¸µéÀÌ ÀǹÌÇÏ´Â ¹Ù¿¡ ´ëÇؼ´Â º°µµÀÇ ¹®¼¸¦ Âü°íÇÏ¿© Áֽñ⠹ٶø´Ï´Ù.
Á¦°¡ ¼öÁ¤ÇÑ ºÎºÐ¿¡ ´ëÇؼ¸¸ ¾ð±ÞÇÏ¿´½À´Ï´Ù.
{{{
# vim /etc/httpd/conf/httpd.conf
}}}
¼¹ö°ü¸®ÀÚÀÇ email ÁÖ¼Ò¸¦ ÀÔ·ÂÇØÁÝ´Ï´Ù. ¿¡·¯ÆäÀÌÁö¿¡ Ç¥½ÃµË´Ï´Ù.
{{{
ServerAdmin root@localhost
}}}
ÁÖ¼®À» Ç®¾îÁÝ´Ï´Ù. ºê¶ó¿ìÀú¿¡¼ http://127.0.0.1/~°èÁ¤ À¸·Î Á¢¼ÓÇϸé /home/°èÁ¤/public_html/ ¿¡¼ À¥¹®¼À» ã°Ô µË´Ï´Ù.
{{{
UserDir public_html
}}}
¾ð¾îº° ¿ì¼± ¼øÀ§¶ó°í ÇÕ´Ï´Ù. ko ¸¦ ¸Ç ¾ÕÀ¸·Î ¿Å°ÜÁÝ´Ï´Ù.
{{{
LanguagePriority ko en ca cs da de el eo es et fr he hr it ja ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
}}}
UTF-8 À» »ç¿ëÇϱ⿣ ¾ÆÁ÷ ȯ°æÀÌ ÃæºÐÈ÷ Á¶¼ºµÇÁö ¾ÊÀº °Í °°½À´Ï´Ù. ÀÎÄÚµù ¹æ½ÄÀ» EUC-KR·Î º¯°æÇØÁÝ´Ï´Ù.
{{{
AddDefaultCharset EUC-KR
}}}
* ¹æȺ®¿¡¼ 80¹ø Æ÷Æ®°¡ ¿·È´Â Áö È®ÀÎÇÕ´Ï´Ù.
* ¾ÆÆÄÄ¡ µ¥¸óÀ» ½ÃÀÛÇÕ´Ï´Ù.
{{{
# service httpd start
}}}
* ºê¶ó¿ìÀú¿¡¼ http://127.0.0.1/ ·Î Á¢¼ÓÇغ¾´Ï´Ù. Âü°í·Î Æäµµ¶ó¿¡¼´Â Fedora Core Test Page °¡ ¶¹½À´Ï´Ù.
* ¾ÆÆÄÄ¡ µ¥¸óÀ» ³¡³»·Á¸é ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇÕ´Ï´Ù.
{{{
# service httpd stop
}}}
= !J2SE =
Fedora core 5 ¿¡¼´Â JDK 5.0 À» rpm.bin À» ¹Þ¾Æ¼ ¼³Ä¡ÇÒ °æ¿ì¿¡ °¢Á¾ °æ·Î ¼³Á¤ ¹®Á¦°¡ ¹ß»ýÇÏ°Ô µË´Ï´Ù.
µû¶ó¼ ´ÙÀ½ ½ÎÀÌÆ®¿¡ ³ª¿ÍÀÖ´Â ¹æ¹ýÀ» »ç¿ëÇß½À´Ï´Ù. http://www.fedorafaq.org/#java
±× ¿ÜÀÇ È¯°æ¿¡¼´Â JavaInstallation ¿¡ ³ª¿ÍÀÖ´Â ¼³Ä¡ ¹æ¹ýÀ» µû¸£½Ã±â ¹Ù¶ø´Ï´Ù.
* sun.com ȨÆäÀÌÁö¿¡¼ ´Ù¿î·Îµå ¹Þ½À´Ï´Ù.
Linux Platform - J2SE(TM) Development Kit 5.0 Update 7 - Linux self-extracting file ( Linux RPM in self-extracting file ÀÌ ¾Æ´Õ´Ï´Ù. )
http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=jdk-1.5.0_07-oth-JPR&SiteId=JSC&TransactionId=noreg
* rpm-build ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÕ´Ï´Ù.
{{{
# yum -y install rpm-build
}}}
* ´Ù¿î ¹ÞÀº JDK ÆÄÀÏÀ» ºôµå¸¦ À§Çؼ source µð·ºÅ丮·Î À̵¿ ½Ãŵ´Ï´Ù.
{{{
# mv jdk-1_5_0_07-linux-i586-rpm.bin /usr/src/redhat/SOURCES/
}}}
* JPackage »çÀÌÆ®¿¡¼ Java 1.5.0.07 Source RPM. À» ´Ù¿î ¹Þ½À´Ï´Ù. - http://www.jpackage.org/rpm.php?id=3557
http://mirrors.dotsrc.org/jpackage/1.6/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm
* java rpm À» ºôµåÇÕ´Ï´Ù.
{{{
# rpmbuild --rebuild java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm
}}}
²Ï ¿À·¡ ÀÛ¾÷ÇÕ´Ï´Ù. Ä¿ÇÇ µå½Ã¸é¼ ±â´Ù¸³´Ï´Ù.
* ºôµåµÈ rpm À» ¼³Ä¡ÇÕ´Ï´Ù.
{{{
# yum -y localinstall /usr/src/redhat/RPMS/i586/java-1.5.0-sun-*
}}}
Á¦ °æ¿ì¿¡´Â nosigned ¸Þ½ÃÁö¿Í ÇÔ²² ¼³Ä¡°¡ µÇÁö ¾Ê¾Ò½À´Ï´Ù. ÀÌ °æ¿ì¿¡´Â rpm -Uvh ·Î ¼³Ä¡ÇØÁÖ¸é µË´Ï´Ù.
¼³Ä¡ÇÏ´Â ÆÐÅ°Áö Áß¿¡ unixODBC-devel ÆÐÅ°Áö¿¡ ÀÇÁ¸¼ºÀÌ ÀÖ´Â ÆÐÅ°Áö°¡ ÀÖÀ¸´Ï ¸ÕÀú ¼³Ä¡ÇØÁÝ´Ï´Ù.
{{{
# yum -y install unixODBC-devel
# rpm -Uvh ~~
}}}
* ¼³Ä¡°¡ Á¤»óÀûÀ¸·Î µÇ¾ú´Â Áö È®ÀÎÇغ¾´Ï´Ù.
{{{
# java -version
}}}
java version "1.5.0_07" °ú °°ÀÌ ³ª¿À¸é ¼º°øÀÔ´Ï´Ù.
¸¸¾à 1.4.2 ¹öÀüÀ¸·Î ³ª¿Â´Ù¸é alternatives ¿¡¼ java °¡ manual mode·Î 1.4.2 ¹öÀü µð·ºÅ丮¸¦ ¸µÅ©·Î »ï°í ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù.
´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇϽðųª
{{{
# alternatives --auto java
}}}
´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÇÑ ÈÄ¿¡ 1.5.0 ¹öÀü °æ·Î¸¦ ¼±ÅÃÇØÁÖ½Ã¸é µË´Ï´Ù.
{{{
# alternatives --confige java
}}}
= Tomcat 5.5 =
* yum À» ÀÌ¿ëÇؼ °ü·Ã rpm ÆÐÅ°ÁöµéÀ» ¼³Ä¡ÇÕ´Ï´Ù.
{{{
# yum -y install tomcat5\*
}}}
* ¹æȺ®¿¡¼ 8080Æ÷Æ®¸¦ ¿¾îÁÝ´Ï´Ù.
* ´ÙÀ½ ÆÄÀÏÀ» ¼öÁ¤ÇÕ´Ï´Ù.
{{{
# vim /usr/share/tomcat5/bin/relink
}}}
ÀÌ ±¸¹®À» ã¾Æ¼ -type d ¿É¼ÇÀ» µÞÆíÀ¸·Î ¿Å°ÜÁØ´Ù.
find /var/lib/tomcat5/webapps -type d -mindepth 1 -maxdepth 2
{{{
find /var/lib/tomcat5/webapps -mindepth 1 -maxdepth 2 -type d
}}}
* ´ÙÀ½ ÆÄÀÏÀ» ¼öÁ¤ÇÕ´Ï´Ù.
{{{
# vim /usr/share/tomcat5/conf/workers.properties
}}}
{{{
#workers.tomcat_home=/var/tomcat
workers.tomcat_home=/usr/share/tomcat5
#workers.java_home=/opt/IBMJava2-13
workers.java_home=/usr/lib/jvm/java
}}}
* tomcat5 adminÅø¿¡¼ »ç¿ëµÇ´Â °èÁ¤ Á¤º¸°¡ ´ã°Ü ÀÖ½À´Ï´Ù. ¼öÁ¤ÇØÁÝ´Ï´Ù. ( adminpassword ºÎºÐÀº ¿øÇϽô Æнº¿öµå¸¦ ÀÔ·ÂÇϼ¼¿ä. )
{{{
# vim /usr/share/tomcat5/conf/tomcat-users.xml
}}}
{{{
}}}
* »ç¿ëÀÚ °èÁ¤À» Áö¿øÇϱâ À§ÇÏ¿© ¼öÁ¤ÇØÁÝ´Ï´Ù.
{{{
# vim /usr/share/tomcat5/conf/server.xml
}}}
{{{
...
...
}}}
ÀûÀýÇÑ È£½ºÆ® ¾Æ·¡¿¡ ´ÙÀ½ÀÇ Listener¸¦ Ãß°¡ÇÏ°Ô µÇ¸é /etc/passwd ÆÄÀÏÀ» Âü°í·Î Çؼ
http://127.0.0.1:8080/~user_account ·Î µé¾î¿Â Á¢¼ÓÀ» /home/user_account/public_html ·Î ¿¬°áÇÏ¿© Áشٰí ÇÕ´Ï´Ù.
* tomcatÀ» ½ÇÇàÇÕ´Ï´Ù.
{{{
# service tomcat5 start
}}}
ºê¶ó¿ìÀú¿¡¼ http://127.0.0.1:8080/·Î Á¢¼ÓÇغ¾´Ï´Ù. °í¾çÀÌ°¡ ³ªÅ¸³ª¸é OK.
* ÀÌÁ¦ tomcatÀ» Á¾·á½Ãŵ´Ï´Ù.
{{{
# service tomcat5 stop
}}}
= mod_proxy_ajp =
mod_proxy_ajp.conf ¿¡ ±â¼úµÈ mod_proxy_ajp À» ÀÌ¿ëÇÏ´Â ¹æ¹ýÀº
´ÙÀ½°ú °°ÀÌ ¼³Á¤ÇÏ¿© ÁÜÀ¸·Î¼ ƯÁ¤ URL·Î µé¾î¿Â ¿äûÀº ÀüºÎ ÅèĹÀÌ Ã³¸®ÇÏ°Ô ÇÏ´Â °ÍÀÔ´Ï´Ù.
{{{
ProxyPass /tomcat/ ajp://localhost:8009/
}}}
ÀÌ °æ¿ì¿¡´Â jsp³ª ¼ºí¸´°ú html ¹®¼¿Í À̹ÌÁöµîÀ» ¼·Î °æ·Î¸¦ ±¸ºÐÇؼ ÀúÀåÇØ¾ß º»·¡ÀÇ ¸ñÀûÀ» ´Þ¼ºÇÒ ¼ö ÀÖ´Ù´Â ¹®Á¦Á¡ÀÌ ÀÖ½À´Ï´Ù.
µû¶ó¼ mod_rewirte ¸¦ ÀÌ¿ëÇؼ .jsp ÆÄÀϸ¸ ÅèĹÀÌ Ã³¸®ÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇÏ¿´½À´Ï´Ù.
* proxy_ajp.conf ÆÄÀÏÀ» ¿¾î¼ ´ÙÀ½°ú °°ÀÌ Ãß°¡ÇØÁÝ´Ï´Ù.
{{{
# vim /etc/httpd/conf.d/proxy_ajp.conf
}}}
{{{
RewriteEngine On
#RewriteLog /root/mod_proxy_ajp.txt
#RewriteLogLevel 9
RewriteCond %{REQUEST_FILENAME} .jsp
RewriteRule (.*) ajp://localhost:8009$1 [P]
}}}
* Tomcat5 ÀÇ È¨µð·ºÅ丮¸¦ /var/www ·Î º¯°æÇØÁÝ´Ï´Ù.
{{{
# cd /usr/share/tomcat5/webapps/ROOT
# mv ROOT ROOT.old
# ln -s /var/www/html /usr/share/tomcat5/webapps/ROOT
# cp -r /usr/share/tomcat5/webapps/ROOT.old/WEB-INF/ /usr/share/tomcat5/webapps/ROOT/WEB-INF
}}}
* ¾ÆÆÄÄ¡ µ¥¸óÀ» ½ÇÇàÇÕ´Ï´Ù.
{{{
# service httpd start
}}}
* tomcat À» ½ÇÇàÇÕ´Ï´Ù.
{{{
# service tomcat5 start
}}}
* Å×½ºÆ®¿ëÀ¸·Î test.jsp ÆÄÀÏÀ» ÀÛ¼ºÇÕ´Ï´Ù.
{{{
# vim /var/www/html/test.jsp
}}}
{{{
<%@ page contentType="text/html; Charset=EUC-KR" %>
<%
out.println("Hello");
%>
}}}
* ºê¶ó¿ìÀú¿¡¼ http://127.0.0.1/test.jsp ¸¦ ¿¾îº¾´Ï´Ù. Hello ¶ó°í¸¸ ³ª¿Â´Ù¸é OK.
= ±âŸ »çÇ× =
Æäµµ¶ó¿¡¼ service ¸í·É¾î¸¦ ÀÎ½Ä ¸øÇÒ ¶§´Â
ÀÏ¹Ý °èÁ¤¿¡¼ root °èÁ¤À¸·Î ³Ñ¾î°¥ ¶§ su ¶ó°í¸¸ ÃÄÁ༠/sbin µð·ºÅ丮°¡ PATH ¿¡ Ãß°¡µÇÁö ¾ÊÀº °æ¿ìÀÏ ¼öµµ ÀÖ½À´Ï´Ù.
{{{
# . /etc/profile
}}}
ÇϽøé PATH °¡ ÀûÀýÇÏ°Ô °»½ÅµÇ¸ç service ¸í·É¾î°¡ Á¦´ë·Î ÀÎ½ÄµÉ °ÍÀÔ´Ï´Ù. ´ÙÀ½ºÎÅÍ´Â su - ¶ó°í ÀÔ·ÂÇϽô °Ô ¹Ù¶÷Á÷ÇÕ´Ï´Ù.
¹¹ Á¦°¡ Àß ¸ô¶ó¼ ±×·¨½À´Ï´Ù. Èå´ÃÈå´Ã
= Âü°í »çÀÌÆ® =
¾Æ·¡ÀÇ ¹®¼µé ´öºÐ¿¡ ¹«»çÈ÷ Ç×Çظ¦ ¸¶Ä¡°í ¶ó²Ù¶ó²Ù ¼ÓÀ¸·Î µé¾î°¡º¾´Ï´Ù. °¨»çÇÕ´Ï´Ù.
* tomcat5 apache2 mod_jk.so ¿¬µ¿ - 2006/06/12 [[BR]]
http://kldp.org/node/71058
* ¾ÆÆÄÄ¡ ¼¹öÀÇ ÃÖ±Ù °³¹ß µ¿Çâ - 2005/07/31 [[BR]]
http://www.yeskisti.net/yesKISTI/Briefing/Analysis/TrendView.jsp?seq=93277&What=TREND&Type=THEME&Query=((CC1:F))
* ¾ÆÆÄÄ¡¿Í ÅèĹ ÇÁ·Ï½Ã·Î ¿¬°áÇϱâ - 2002/08/18[[BR]]
http://www.javaservice.net/~java/bbs/read.cgi?m=appserver&b=engine&c=r_p&n=1029620887&k=ÇÁ·Ï½Ã&d=tb#1029620
* mod_jk is dead. Long live mod_proxy_ajp - 2006/02/01[[BR]]
http://getahead.ltd.uk/blog/joe/2006/02/01/1138781915484.html
* Apache Module mod_proxy_ajp [[BR]]
http://httpd.apache.org/docs/2.2/en/mod/mod_proxy_ajp.html
* Tomcat FAQ 'Connectors' [[BR]]
http://tomcat.apache.org/faq/connectors.html
* Tomcat °£´ÜÈ÷ rpm À¸·Î -2003.02.24[[BR]]
http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=17142
* ¾ÆÆÄÄ¡ rewrite ¸ðµâ[[BR]]
http://www.superuser.co.kr/apache/rewrite_Module/Apache_rewrite_Module.htm
* Apache Module mod_rewirte[[BR]]
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
* ÅèĹÀÇ »ç¿ëÀÚ °èÁ¤ Áö¿ø - 2002.12.16[[BR]]
http://www.javaservice.net/~java/bbs/read.cgi?b=qna2&c=r_p&n=1039985093
= Çǵå¹é =
¹¹¶óµµ ±¦ÂúÀ¸´Ï ÇѸ¶µð¾¿ ½áÁÖ°í °¡¼¼¿ä. ;¤±;
À½ ±Â ¤»? -- ddakker
Àß ÀÐ°í °©´Ï´Ù. ¼ö°í¿¡ °¨»çµå¸³´Ï´Ù. :-) -- allieus
ÁÁÀº ¹®¼ °¨»çÇÕ´Ï´Ù. ^^
ÀúÈñµµ proxy_ajp¸¦ »ç¿ëÇϴµ¥ Àú·¸°Ô rewrite¸¦ ÀÌ¿ëÇؼ ƯÁ¤ È®ÀåÀÚ¿¡ ´ëÇؼ¸¸ ó¸® ÇÒ ¼öµµ ÀÖ±º¿ä. jk Ä¿³ØÅͺ¸´Ù ÈξÀ ÆíÇϱâ´Â ÇÕ´Ï´Ù. ÁÁÀº ±Û °¨»çÇÕ´Ï´Ù.
¾Æ³ö »óÇöÀÌÇü;;; À̸§ÀÌ Àͼ÷ŸÇß´õ´Ï ¿ª½ÃÇüÀ̾ú¾î;; -- ¸ÖƼ ½Ç½ÀÁ¶±³ ¤»¤»