Á¦¸ñ : [kHTTPd] with Apache 1.3 ÀÛ¼ºÀÚ : ±èÄ¥ºÀ[´Ð: »êÀÌ] san2(at)linuxchannel.net 2001.02.26 : 1Â÷ ¿Ï·á ---------------------------------------------------------------------------- ÀÌ ¹®¼­´Â ¸®´ª½º Ä¿³Î ¼öÁØ¿¡¼­ ±¸µ¿µÇ´Â kHTTPd 0.1.6(À¥¼­¹ö)¿Í ¾ÆÆÄÄ¡ ¿¬µ¿À» À§ÇÑ ±âÃÊÀûÀÎ ÆÁ¹®¼­ÀÔ´Ï´Ù. ÀÌ ¹®¼­ÀÇ ÃֽŠ¹öÀüÀº ´ÙÀ½¿¡ ½ÎÀÌÆ®¿¡¼­ ãÀ» ¼ö ÀÖ½À´Ï´Ù. http://www.linuxchannel.net/docs/ ÀÌ ¹®¼­ÀÇ ÀúÀÛ±ÇÀº GNU GPL¿¡ µû¸¨´Ï´Ù. ---------------------------------------------------------------------------- *ÁÖ) ¹®¸Æ»ó °£È¤ °æ¾î¸¦ »ý·«Çß½À´Ï´Ù. ¾çÇØÇØ ÁÖ½Ã±æ ¹Ù¶ø´Ï´Ù. kHTTPd¿¡ ´ëÇؼ­ ±×¸® ¸¹Àº ÇعÚÇÑ Áö½ÄÀÌ ¾ø±â ¶§¹®¿¡ ¹®¼­»ó º¸¿ÏÀ̳ª À߸øµÈ ³»¿ëÀÌ ÀÖÀ¸¸é ¾ðÁ¦µçÁö ȯ¿µÇÕ´Ï´Ù. ----------------------------------------------------------------------------- ¸ñÂ÷ 1. ¹è°æ 2. °ü·Ã ¹®¼­ 3. kHTTPd ¼Ò°³ 3-1. °£´ÜÇÑ ¼Ò°³ 3-2. kHTTPd°¡ Á¦°øÇÏ´Â Á¶°Ç 3-3. Ä¿³Î ÄÄÆÄÀÏ ¿ä±¸ »çÇ× 3-4. kHTTPd ¼³Á¤ ÆĶó¹ÌÅÍ 3-5. kHTTPd ½ÃÀÛ°ú Á¾·á 4. ¾ÆÆÄÄ¡¿Í ¿¬µ¿ 4-1. kHTTPd¸¦ ¾î¶² ¿ëµµ·Î »ç¿ëÇÒ °ÍÀΰ¡? 4-2. [ÆÁ] PHP ÇÔ¼ö ÀÌ¿ë 4-3. [ÆÁ] ¾ÆÆÄÄ¡ rewrite ¸ðµâ ÀÌ¿ë 5. °£´ÜÇÑ ¼º´É Å×½ºÆ® 6. Áú¹®°ú ´äº¯ 7. ¸¶Ä¡¸ç 8. ºÎ·Ï - kHTTPd Á¦¾î ½©½ºÅ©¸³Æ® 1. ¹è°æ ÇÊÀÚ´Â ¿¹ÀüºÎÅÍ ¾ÆÆÄÄ¡ ¼­¹ö¸¦ ¿î¿µÇØ ¿À¸é¼­ °¡Àå ºÒ¸¸(?)À̾ú´ø °ÍÀÌ ¹Ù·Î ´À¸®°Ô ·ÎµùµÇ´Â ±×¸²À̹ÌÁö¿´´Ù. Á¦¿ì½º À¥¼­¹öó·³ ¾î¶»°Ô »¡¸® ·ÎµùÇÏ´Â ¹æ¹ýÀÌ ¾øÀ»±î ÇÏ´Â »ý°¢¿¡ °ñ¸Ó¸®¸¦ ¾Î´ø Áß¿¡ ¸®´ª½º Ä¿³Î ¼öÁØ¿¡¼­ ±¸µ¿µÇ´Â kHTTPd¸¦ ¾Ë°Ô µÇ¾ú´Ù. ¸®´ª½º Ä¿³Î °³¹ß¹öÀü(2.3.x)ÀÌ ÇÑÂü ÁøÇàÁß¿¡ °ü·Ã ¹®¼­°¡ Àû¾î Çѵ¿¾È ½ÇÆи¸ °Åµì ÇÏ´Ù°¡ µåµð¾î Ä¿³ÎÀ» 2.4.x·Î ¿Ã¸®°í ±×·°Àú·° ¼³Á¤¿¡ ¼º°øÇß´Ù. °á°ú´Â 100% ¸¸Á·ÇÏÁö´Â ¾ÊÁö¸¸, ¾ÆÁ÷ kHTTPdÀÇ ¹öÀüÀÌ 0.1.6À̶ó´Â Á¡¿¡¼­ ¾ÕÀ¸·Î °è¼Ó ÁÖ¸ñÇÏ°íÀÚ ÇÑ´Ù. ¶ÇÇÑ °ü·Ã ¹®¼­°¡ ÀÎÅÍ³Ý»ó¿¡ ±×¸® ¸¹Áö ¾Ê¾Æ ÀÌ ¹®¼­¸¦ ÀÛ¼ºÇÏ°Ô µÇ¾ú´Ù. 2. °ü·Ã ¹®¼­ kHTTPd¿Í °ü·ÃµÈ ¹®¼­´Â ±×¸® ¸¹Áö ¾Ê½À´Ï´Ù. kHTTPd °ü·Ã ȨÆäÀÌÁö : http://www.fenrus.demon.nl/ kHTTPd °ü·Ã ¹®¼­ : /usr/src/<Ä¿³Î2.3.14ÀÌ»ó>/net/khttpd/README ¸ÞÀϸµ ¸®½ºÆ® : khttpd-users@zgp.org ¶Ç´Â khttpd@fenrus.demon.nl ±âŸ : ÇÊÀÚ°¡ ¾Æ´Â ¹®¼­´Â À̰͹ۿ¡ ¾ø±º¿ä. T.T 3. kHTTPd ¼Ò°³ "linux httpd accelerator" kHTTPd´Â ¸®´ª½º Ä¿³Î ¼öÁØ¿¡¼­ ±¸µ¿µÇ´Â HTTPd °¡¼Ó±âÀÔ´Ï´Ù. (C) 1999 by Arjan van de Ven Licensed under the terms of the GNU General Public License 3-1. °£´ÜÇÑ ¼Ò°³(README ¹®¼­¿¡ ÀÇÇϸé) kHTTPd´Â ¸®´ª½º¿ë http µ¥¸ó(À¥¼­¹ö)À̸ç, ¸®´ª½º Ä¿³Î¿¡ ³»ÀåµÇ¾î ÀÖ´Ù´Â Á¡¿¡¼­ ´Ù¸¥ À¥¼­¹ö¿Í ´Ù¸£´Ù. Ä¿³Î ÄÄÆÄÀϽà ¸ðµâ·Î ¼³Á¤Çϰųª Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇÏ¿© »ç¿ëÇÑ´Ù. - 1999³â Arjan van de Ven¿¡ ÀÇÇؼ­ ½ÃÀ۵Ǿú´Ù. - kHTTPd´Â ¿ÀÁ÷ Á¤ÀûÀÎ À¥ÆäÀÌÁö(html/txt/images/compress file/movies file/...) ¸¸ Á¦°øÇÑ´Ù. - µ¿ÀûÀÎ ÆäÀÌÁö´Â ´Ù¸¥ À¥¼­¹ö(¾ÆÆÄÄ¡³ª Á¦¿ì½º)·Î ³Ñ±ä´Ù. - Á¤ÀûÀÎ ÆäÀÌÁö´Â Ä¿³ÎÂ÷¿ø¿¡¼­ ó¸®Çϱ⠶§¹®¿¡ ¼Óµµ°¡ ºü¸£´Ù. - Ä¿³Î 2.3.14 ÀÌ»ó. - ÇöÀç ¹öÀüÀº 0.1.6c±îÁö ³ª¿Í ÀÖÁö¸¸ Ä¿³Î 2.4.1¿¡¼­´Â 0.1.6ÀÇ ³»¿ëÀÌ Àû¿ë. - ±âŸ. 3-2. kHTTPd°¡ Á¦°øÇÏ´Â Á¶°Ç kHTTPd´Â ÆÄÀÏÀÌ ´ÙÀ½°ú °°Àº Á¶°ÇÀÏ °æ¿ì¿¡ ¸¸ ¼­ºñ½ºÇÑ´Ù. 1) URL¿¡ ÁúÀÇ("?")°¡ ¾øÀ» °æ¿ì 2) URLÀÌ "/"À¸·Î ½ÃÀÛÇÒ °æ¿ì 3) URL¿¡ Á¤È®ÇÑ ÆÄÀÏÀ» ¿äûÇÒ °æ¿ì 4) ÆÄÀÏÀÌ Àб⠸ðµåÀÏ °æ¿ì(*) 5) ÆÄÀÏÀÌ µð·ºÅ丮°¡ ¾Æ´Ñ°æ¿ì, ÆÄÀÏ¿¡ ½ÇÇà Æ۹̼ÇÀÌ ¾øÀ» °æ¿ì, Sticky-bit·Î ¼³Á¤µÇ¾î ÀÖÁö ¾ÊÀº °æ¿ì(*) 6) URLÀÌ "forbidden" ¹®ÀÚ¿­À» Æ÷ÇÔÇÏÁö ¾ÊÀ» °æ¿ì, ".."¿Í "cgi-bin"(*) 7) mime-typeÀ» ¾Ë °æ¿ì(*) 8) °¡»óÈ£½ºÆ®´Â Áö¿øÇÏÁö ¾ÊÀ½ 9) ±×¿Ü µ¿ÀûÀÎ ÆäÀÌÁö´Â ¸ðµÎ ´Ù¸¥ À¥¼­¹ö·Î Àü´ÞµÈ´Ù. (*) Ç¥½ÃµÈ Ç׸ñÀº sysctl ÆĶó¹ÌÅ͸¦ ÅëÇؼ­ ¼³Á¤°¡´ÉÇÑ °æ¿ì·Î, /etc/sysctl.conf ¼³Á¤ÆÄÀÏ¿¡ ÀÇÇؼ­ ½Ã½ºÅÛÀÌ ºÎÆõǸ鼭 /proc/sys/net/khttpdÀÇ °¢ ÆĶó¹ÌÅÍ¿¡ ¼³Á¤ÇÑ´Ù. 3-3. Ä¿³Î ÄÄÆÄÀÏ ¿ä±¸ »çÇ× kHTTPd¸¦ »ç¿ëÇϱâ À§Çؼ­´Â ´ÙÀ½°ú °°Àº Ä¿³Î ÄÄÆÄÀÏÀÌ ¿ä±¸µÈ´Ù. ÃÖ¼ÒÇÑ ¸®´ª½º Ä¿³Î 2.3.14 ÀÌ»óÀÇ ¹öÀüÀÌ ÇÊ¿äÇÏ´Ù. (Ä¿³Î 2.4.1 ±âÁØ) Code maturity level options ---> [*] Prompt for development and/or incomplete code/drivers General setup ---> [*] Sysctl support Networking options ---> <*> Kernel httpd acceleration (EXPERIMENTAL) File systems ---> [*] /proc file system support *ÁÖ) ÇÊÀÚÀÇ Å×½ºÆ® ȯ°æ(RedHat 6.2ÀÇ Ä¿³Î 2.4.1)¿¡¼­´Â Kernel httpd acceleration (EXPERIMENTAL)¸ðµâ·Î ¼³Á¤ÇÑÈÄ ¸ðµâÀ» ÀûÀç ÇÒ¶§ ¿¡·¯¸¦ ¹ß»ýÇß´Ù. µû¶ó¼­ ÇÊÀÚ°¡ Å×½ºÆ®ÇÑ °æ¿ì´Â Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇÏ¿© Å×½ºÆ®ÇÑ °æ¿ìÀÓ. ¸¸¾à, /usr/src/linux/.config ÆÄÀÏÀÌ Á¸ÀçÇÑ´Ù¸é, CONFIG_KHTTPD=y ºÎºÐ È®ÀÎ. 3-4. kHTTPd ¼³Á¤ ÆĶó¹ÌÅÍ [¸ðµâ·Î ÄÄÆÄÀÏÇßÀ» °æ¿ì] ¹«»çÈ÷ Ä¿³Î ÄÄÆÄÀÏÀ» ¸ðµÎ ¸¶ÃÆ´Ù´Â °¡Á¤ÀÔ´Ï´Ù. ¸¸¾à khttpd¸¦ ¸ðµâ·Î ÄÄÆÄÀÏÇß´Ù¸é ±¸µ¿Çϱâ Àü¿¡ ¸ðµâÀÌ Á¸ÀçÇÏ´ÂÁö ´ÙÀ½°ú °°ÀÌ ¾Ë¾Æº»´Ù. # ls /lib/modules/`uname -r`/kernel/net/khttpd/khttpd.o khttpd.o # *ÁÖ) `uname -r`¿¡¼­ ` ¹®ÀÚ´Â ' ¹®ÀÚ°¡ ¾Æ´Ñ ~ ¹®ÀÚ°¡ ÀÖ´Â ÀÚÆÇÅ°ÀÔ´Ï´Ù. ¸ðµâ·Î ÄÄÆÄÀÏÇ߱⠶§¹®¿¡ khttpdÀ» ±¸µ¿Çϱâ Àü¿¡ ¸Þ¸ð¸®¿¡ ÀÌ ¸ðµâÀ» ¿Ã·Á¾ßÇÕ´Ï´Ù. ¸ðµâ ¿Ã¸®±â : # modprobe khttpd ¸ðµâ ³»¸®±â : (¸ÕÀú khttpd¸¦ stop ÇؾßÇÔ) # rmmod khttpd *ÁÖÀÇ) ¸¸¾à sysctl.conf ÆÄÀÏÀ» ÀÌ¿ëÇؼ­ ½Ã½ºÅÛÀÌ ºÎÆÃÇÒ¶§ ÀÚµ¿À¸·Î ¸ðµâÀ» ¿Ã¸®·Á¸ç /etc/rc.d/rc.sysinit ÆÄÀÏÀ» ¿­¾î "sysctl -p /etc/sysctl.conf" ºÎºÐÀ» ã¾Æ ±× ÀÌÀü¿¡ ¸ðµâÀ» ¿Ã¸®´Â ¸í·ÉÀ» Ãß°¡ÇØÁà¾ß ÇÔ. [Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇßÀ» °æ¿ì] # ps -ef | grep khttpd root 8 1 0 Feb19 ? 00:00:00 [khttpd manager] root 566 8 0 Feb19 ? 00:00:01 [khttpd - 0 ] # À§¿Í °°Àº ³»¿ëÀ» º¼ ¼ö ÀÖÀ» °Ì´Ï´Ù. ±×·³ ÀÌÁ¦ kHTTPd¸¦ ¼³Á¤Çϱâ Àü¿¡ ¾î¶² ³»¿ëÀ» ¼³Á¤ÇؾßÇÏ´ÂÁö ¾Ë¾Æº¾½Ã´Ù. # ls -l /proc/sys/net/khttpd -rw-r--r-- 1 root root 0 Feb 22 07:31 clientport -rw-r--r-- 1 root root 0 Feb 22 07:31 documentroot -rw-r--r-- 1 root root 0 Feb 22 07:31 dynamic -rw-r--r-- 1 root root 0 Feb 22 07:31 logging -rw-r--r-- 1 root root 0 Feb 22 07:31 maxconnect -rw-r--r-- 1 root root 0 Feb 22 07:31 perm_forbid -rw-r--r-- 1 root root 0 Feb 22 07:31 perm_required -rw-r--r-- 1 root root 0 Feb 22 07:31 serverport -rw-r--r-- 1 root root 0 Feb 22 07:31 sloppymime -rw-r--r-- 1 root root 0 Feb 22 07:31 start -rw-r--r-- 1 root root 0 Feb 22 07:31 stop -rw-r--r-- 1 root root 0 Feb 22 07:31 threads -rw-r--r-- 1 root root 0 Feb 22 07:31 unload # /proc/sys/net/khttpd¿¡ 13°³ÀÇ kHTTPD Ä¿³Î ÆĶó¹ÌÅÍ°¡ ÀÖ½À´Ï´Ù. °¢°¢ÀÇ ÆĶó¹ÌÅÍ¿¡ ¼³Á¤°ªÀ» ÀÔ·ÂÇÏ´Â Çü½ÄÀº ´ÙÀ½°ú °°½À´Ï´Ù. ¿¹) # echo "/home/httpd/html" > /proc/sys/net/khttpd/documentroot ÇϳªÇϳª¾¿ ¾Ë¾Æº¾½Ã´Ù. - serverport [8080] kHTTPd°¡ »ç¿ëÇÒ Æ÷Æ®¹øÈ£¸¦ ÀǹÌÇϸç, ±âº»°ªÀº 8080Æ÷Æ®¸¦ »ç¿ëÇÕ´Ï´Ù. ¸¸¾à serverport¸¦ 80 Æ÷Æ®·Î ¼³Á¤ÇÒ °æ¿ì´Â clientport¸¦ 80 Æ÷Æ® ¿ÜÀÇ Æ÷Æ® ¸¦ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù(Çʼö¼³Á¤). - clientport [80] kHTTPd°¡ ¾Æ´Ñ ´Ù¸¥ À¥¼­¹ö(¿¹:¾ÆÆÄÄ¡)°¡ »ç¿ëÇÒ Æ÷Æ® ¹øÈ£¸¦ ÀǹÌÇÕ´Ï´Ù. ±âº»°ªÀº 80 Æ÷Æ®·Î ¼³Á¤µÇ¾î ÀÖÀ¸¸ç serverport¿Í ¹Ý´ë·Î ¼­·Î Æ÷Æ®°¡ °°Áö ¾Ê°Ô ¼³Á¤ÇØ¾ß ÇÕ´Ï´Ù(Çʼö¼³Á¤). - documentroot [/var/www] kHTTPd°¡ Á¦°øÇÒ ±âº» DocumentRoot¸¦ ÀǹÌÇÕ´Ï´Ù. ¾ÆÆÄÄ¡ ¼­¹ö¸¦ »ç¿ëÇÑ´Ù¸é ¾ÆÆÄÄ¡ ¼­¹ö¿¡¼­ ¼³Á¤ÇÑ ±âº» DocumentRoot¿Í °°°Ô ¼³Á¤ÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ¹°·Ð ´Ù¸¥ ¿ëµµ·Î »ç¿ëÇÑ´Ù¸é ÇØ´ç DocumentRoot¸¦ ÁöÁ¤ÇÏ¸é µË´Ï´Ù. ±âº»°ªÀº /var/www ÀÔ´Ï´Ù(Çʼö¼³Á¤). - start [0] kHTTPdÀÇ ½ÃÀÛ(±¸µ¿)À» ¼³Á¤ÇÏ´Â ºÎºÐÀ¸·Î 1·Î ¼³Á¤Çϸé kHTTPd°¡ ½ÃÀ۵ȴÙ. 1·Î ¼³Á¤Çϸé stopÀº 1·Î ¼³Á¤(Çʼö¼³Á¤). - stop [0] kHTTPdÀÇ Á¾·á¸¦ ¼³Á¤ÇÏ´Â ºÎºÐÀ¸·Î 1·Î ¼³Á¤Çϸé kHTTPd´Â Á¾·áµÈ´Ù. ¸¶Âù°¡Áö·Î 1·Î ¼³Á¤Çϸé startÀº 0À¸·Î ¼³Á¤(Çʼö¼³Á¤). - dynamic [cgi-bin ..] µ¿ÀûÀ¸·Î ¿òÁ÷ÀÌ´Â ÆäÀÌÁö(URL)¸¦ ¼³Á¤ÇÏ´Â Ç׸ñÀ¸·Î ÀÌ ºÎºÐÀº ´Ù¸¥ À¥¼­¹ö·Î Àü´Þ µË´Ï´Ù. cgi-binÀ̳ª php µîµîÀÌ ÀÌ¿¡ ÇØ´çµÊ. - logging [0] kHTTPd°¡ ·Î±×¸¦ ±â·ÏÇÒ °ÍÀΰ¡ÀÇ ¿©ºÎÀÌ´Ù. 0À¸·Î ¼³Á¤ÇÏ¸é ·Î±×¸¦ ±â·ÏÇÏÁö ¾Ê°í 1·Î ¼³Á¤ÇÏ¸é ·Î±×¸¦ ±â·ÏÇÑ´Ù. ±×·¯³ª 0.1.6 ¹öÀüÀº ±âº»ÀûÀ¸·Î ·Î±×¸¦ ±â·ÏÇÏÁö ¾Ê´Â´Ù. ´Ù¸¸ 0.1.6c ¹öÀü¿¡¼­´Â ·Î±×¸¦ ±â·ÏÇϵµ·Ï µÇ¾î ÀÖÀ¸³ª À̶§´Â khttpdlog ¿Í °°Àº µ¥¸óÀÌ ÇÊ¿äÇÏ´Ù. http://www.fenrus.demon.nl/ ¸¦ ¹æ¹®Çϸé sample khttpdlog°¡ ÀÖ½À´Ï´Ù. ÇÊÀÚ´Â ¾ÆµÐÇÏ°Ôµµ kHTTPd¸¦ 0.1.6c ÆÐÄ¡ÇÏ°í ÀÌ sample khttpdlog¸¦ ºôµåÇÏ¿© Å×½ºÆ®ÇØ º¸¾ÒÀ¸³ª ·Î±× ±â·Ï¿¡ ½ÇÆÐÇß´Ù. ¸» ±×´ë·Î sample µ¥¸óÀÓ. ½Ç·ÂÀÖ´Â ºÐÀº 0.1.6c·Î ÆÐÄ¡ÇÏ°í sample khttpdlog¸¦ ¼öÁ¤(?)ÇÏ¿© Å×½ºÆ®ÇØ º¸½Ã±æ ¹Ù¶ø´Ï´Ù. Âü°í·Î, Ä¿³Î 2.4.1¿¡¼­ kHTTPd 0.1.6c ¹öÀüÀ¸·Î ÆÐÄ¡ÇÏ´Â ÆÄÀÏÀº ¾Æ·¡ ½ÎÀÌÆ®¿¡ ÀÖ½À´Ï´Ù. http://ftp.linuxchannel.net/devel/khttpd/patch-khttpd-0.1.6c-for-2.4.1.txt - maxconnect [1000] ÃÖ´ë µ¿½Ã Á¢¼ÓÀÚ ¼ö¸¦ ¼³Á¤ÇÏ´Â ºÎºÐÀÔ´Ï´Ù. ¾ÆÆÄÄ¡ÀÇ MaxClients¿Í ºñ½ÁÇÑ ¼³Á¤ÀÌ¸ç ±âº»°ªÀº 1000À¸·Î µÇ¾î ÀÖÀ½. - perm_forbid [dir+sticky+execute] "forbidden"¿¡ ´ëÇÑ ÆÛ¹Ì¼Ç ¸Å½ºÅ© ¼³Á¤. ±âº»°ª(?)Àº 16969ÀÓ. ÀÚ¼¼ÇÑ ³»¿ëÀº System calls "man 2 stat" Âü°í. Âü°í) The `sticky' bit (S_ISVTX) on a directory means that a file in that directory can be renamed or deleted only by the owner of the file, by the owner of the directory, and by root. - perm_required [S_IROTH] ÃÖ¼ÒÇÑÀÇ ÆÛ¹Ì¼Ç ¼³Á¤. ±âº»°ªÀº 4(read)ÀÓ. ÀÚ¼¼ÇÑ ³»¿ëÀº System calls "man 2 stat" Âü°í. Âü°í) S_IROTH 00004 others have read permission - sloppymime [0] ¸¶ÀÓŸÀÔ¿¡ °üÇÑ ¼³Á¤ÀÔ´Ï´Ù. ¾ËÁö ¸øÇÏ´Â ¸¶ÀÓŸÀÔ¿¡ ´ëÇؼ­ 0À¸·Î ¼³Á¤Çϸé text/htmlÀ¸·Î ¼³Á¤µÇ°í, 1·Î ¼³Á¤ÇÏ¸é ´Ù¸¥ À¥¼­¹ö(¿¹:¾ÆÆÄÄ¡)·Î ³Ñ°ÜÁý´Ï´Ù. ±âº»°ªÀº 0ÀÔ´Ï´Ù. - threads [2] kHTTPdÀÇ ¾²·¹µå ¼öÀÌ´Ù. ºñ±³Àû ÀÛÀº À¥½ÎÀÌÆ® ÀÏ °æ¿ì CPU´ç 1À» °öÇÑ ¼ö¸¦ ¼³Á¤ÇÏ°í ºñ±³Àû Å« ±Ô¸ðÀÏ °æ¿ì CPU´ç 2¸¦ °öÇÑ ¼ö°¡ Àû´çÇÔ. ±âº»°ªÀº 2. - unload [0] kHTTPd¸¦ Ä¿³ÎÀÇ ¸ðµâ·Î ÄÄÆÄÀÏÇßÀ» °æ¿ì¿¡ ÇØ´çµÇ¸ç ¸Þ¸ð¸®¿¡¼­ ¸ðµâÀ» Á¦°ÅÇÒ °æ¿ì¿¡´Â 1·Î ¼³Á¤ÇÑ´Ù. ±âº»°ªÀº 0. ÁÖÀÇ) kHTTPd¸¦ Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇß´Ù¸é 0À¸·Î °è¼Ó ¼³Á¤ÇØ ³õ´Â´Ù. ¹Ý¸é ¸ðµâ·Î ÄÄÆÄÀÏÇÏ¿© khttpd ¸ðµâÀ» ¸Þ¸ð¸®¿¡¼­ Á¦°ÅÇÏ·Á¸é kHTTPd¸¦ ¹Ýµå½Ã Á¾·áÇÏ°í unload 1·Î ¼³Á¤ÇØ¾ß ÇÔ. 3-5. kHTTPd ½ÃÀÛ°ú Á¾·á ±×·³ ½ÇÁ¦·Î kHTTPd¸¦ ±¸µ¿ÇÏ°í ¸ØÃ纸ÀÚ. ÁÖÀÇ) ¾ÆÆÄÄ¡¿Í °°ÀÌ ¿¬µ¿ÇÑ´Ù¸é ¾ÆÆÄÄ¡¸¦ ½ÇÇàÇϱâ Àü¿¡ kHTTPd¸¦ ¸ÕÀú ½ÇÇàÇØ¾ß ÇÔ. [kHTTPd¸¦ ¸ðµâ·Î ÄÄÆÄÀÏÇßÀ» °æ¿ì] kHTTPd¸¦ ¸ðµâ·Î ÄÄÆÄÀÏÇß´Ù¸é ¸ÕÀú khttpd¸¦ ¸Þ¸ð¸®¿¡ ÀûÀçÇؾßÇÑ´Ù. - kHTTPd ½ÃÀÛ # modprobe khttpd # echo 1 > /proc/sys/net/khttpd/start - kHTTPd È®ÀÎ # ps -ef | grep khttpd root 8 1 0 Feb19 ? 00:00:00 [khttpd manager] root 23803 8 0 Feb22 ? 00:00:00 [khttpd - 0] root 23804 8 0 Feb22 ? 00:00:00 [khttpd - 1] # khttpd ¸Å´ÏÀú¿Í µÎ°³ÀÇ ÇÁ·Î¼¼½º°¡ ´õ ÀÖÀ½À» ¾Ë ¼ö ÀÖ´Ù. - kHTTPd Á¾·á # echo 1 > /proc/sys/net/khttpd/stop # echo 1 > /proc/sys/net/khttpd/unload # rmmod khttpd [kHTTPd¸¦ Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏ ÇßÀ» °æ¿ì] À§¿Í µ¿ÀÏÇ쵂 modprobe¿Í unload, rmmod ³»¿ëÀº »ý·«µÈ´Ù. Áï, - kHTTPd ½ÃÀÛ # echo 1 > /proc/sys/net/khttpd/start - kHTTPd Á¾·á # echo 1 > /proc/sys/net/khttpd/stop Áö±Ý±îÁö ±âº»ÀûÀÇ kHTTPdÀÇ ½ÃÀÛ°ú Á¾·á¿¡ ´ëÇؼ­ ¾Ë¾Æº¸¾Ò½À´Ï´Ù. º¸´Ù °£ÆíÇÏ°Ô kHTTPd¸¦ ½© ½ºÅ©¸³Æ®·Î ÀÛ¼ºÇؼ­ Á¦¾îÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹Á¦1. kHTTPd¸¦ º¸Á¶ ¼­¹ö·Î »ç¿ëÇÒ °æ¿ì --------------------------------------------------- #!/bin/sh modprobe khttpd echo 80 > /proc/sys/net/khttpd/clientport echo 8080 > /proc/sys/net/khttpd/serverport echo /var/www > /proc/sys/net/khttpd/documentroot echo php3 > /proc/sys/net/khttpd/dynamic echo shtml > /proc/sys/net/khttpd/dynamic echo 1 > /proc/sys/net/khttpd/start ---------------------------------------------------- ¿¹Á¦2. kHTTPd¸¦ ¸ÞÀÎ ¼­¹ö·Î »ç¿ëÇÒ °æ¿ì ---------------------------------------------------- #!/bin/sh modprobe khttpd echo 8080 > /proc/sys/net/khttpd/clientport echo 80 > /proc/sys/net/khttpd/serverport echo /var/www > /proc/sys/net/khttpd/documentroot echo php3 > /proc/sys/net/khttpd/dynamic echo shtml > /proc/sys/net/khttpd/dynamic echo 1 > /proc/sys/net/khttpd/start ----------------------------------------------------- ÀÌ¿Í °°ÀÌ Á÷Á¢ ¸í·É¶óÀο¡¼­ ¼³Á¤ÇÏ´Â ¹æ¹ý¿Ü¿¡ /etc/sysctl.conf ÆÄÀÏÀ» ÀÌ¿ëÇÏ¿© ½Ã½ºÅÛÀÌ ½ÃÀÛÇϸ鼭 ÀÚµ¿À¸·Î ½ÇÇàÇÏ´Â ¹æ¹ýÀÌ ÀÖ½À´Ï´Ù. À̶§´Â ¾Õ¼­ ¾ê±âÇßµíÀÌ ¸ðµâ·Î ÄÄÆÄÀÏ Çß´Ù¸é, /etc/rc.d/rc.sysinit ÆÄÀÏÀ» ¿­¾î "sysctl -p /etc/sysctl.conf" ºÎºÐÀ» ã¾Æ ±× ÀÌÀü¿¡ ¸ðµâÀ» ¿Ã¸®´Â ¸í·ÉÀ» Ãß°¡ÇØÁà¾ßÇÕ´Ï´Ù. Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇß´Ù¸é /etc/rc.d/rc.sysinit ÆÄÀÏ¿¡ Ãß°¡ ÇÒ ÇÊ¿ä´Â ¾ø½À´Ï´Ù. ¿¹Á¦) ------ /etc/sysctl.conf ------------------------------- net.khttpd.clientport = 80 net.khttpd.serverport = 8080 net.khttpd.dynamic = php3 net.khttpd.documentroot = /var/www net.khttpd.start = 1 ------------------------------------------------------ ´«Ä¡°¡ ºü¸£¸é ´ëÃæ net.khttpd°¡ ¾î¶² °ÍÀÎÁö¸¦ ¾Ë ¼ö ÀÖÀ» °Ì´Ï´Ù. Áï /proc/sys/net/khttpd ¸¦ ÀǹÌÇÕ´Ï´Ù(µð·ºÅ丮¸¦ dot(.)À¸·Î ±¸ºÐ?). Âü°í) "8. ºÎ·Ï"À» Âü°íÇϸé ÇÊÀÚ°¡ ¾û¸ÁÀ¸·Î ÀÛ¼ºÇØ ³õÀº ½© ½ºÅ©¸³Æ®°¡ ÀÖ½À´Ï´Ù. ÀÌ´Â kHTTPd¸¦ Ä¿³Î¿¡ Á¤ÀûÀ¸·Î ÄÄÆÄÀÏÇØ ³õÀº »óÅ¿¡¼­ kHTTPd¸¦ ¾ÆÆÄÄ¡ À¥¼­¹öÀÇ º¸Á¶¿ªÇÒÀ» Çϱâ À§ÇÑ °ÍÀÔ´Ï´Ù. Âü°í·ÎÇ쵂 ÀÚ½ÅÀÇ È¯°æ¿¡ ¸Â°Ô °íÃļ­ »ç¿ëÇÏ½Ã±æ ¹Ù¶ø´Ï´Ù. ½Ç·ÂÀÖ´Â ºÐÀº ¾Æ¿¹ ¹«½ÃÇϽñæ............... 4. ¾ÆÆÄÄ¡¿Í ¿¬µ¿ ±×·³ À̹ø¿¡ ½ÇÁ¦·Î ¾ÆÆÄÄ¡¿Í ¿¬µ¿ÇÏ¿© kHTTPd¸¦ »ç¿ëÇØ º¾½Ã´Ù. 4-1. kHTTPd¸¦ ¾î¶² ¿ëµµ·Î »ç¿ëÇÒ °ÍÀΰ¡? ¿ì¼± kHTTPd¸¦ ¾î¶² ¿ëµµ·Î »ç¿ëÇÒ °ÍÀÎÁö¿¡ ´ëÇؼ­ °áÁ¤ÇؾßÇÕ´Ï´Ù. Áï 80 Æ÷Æ® ¼³Á¤¿¡ µû¶ó¼­ kHTTPd°¡ ¸ÞÀμ­¹ö°¡ µÉ ¼ö ÀÖ°í, º¸Á¶ ¼­¹ö°¡ µÉ ¼ö ÀÖ½À´Ï´Ù. kHTTPdÀÇ ¿ëµµ °áÁ¤ÀÇ ±âÁØ(?) 1) µ¿ÀûÀÎ ÆäÀÌÁö´Â ¾ÆÆÄÄ¡°¡ ¼­ºñ½ºÇÑ´Ù. 2) Á¤ÀûÀÎ ÆäÀÌÁö´Â kHTTPd°¡ ¼­ºñ½ºÇÑ´Ù. 3) °¡»óÈ£½ºÆ®¸¦ Æ÷ÇÔÇÑ ¸ðµÎ À¥ÆäÀÌÁö°¡ ¿øÈ°ÇÏ°Ô ¿î¿µµÇ¾î¾ß ÇÑ´Ù.. 4) ºñ±³Àû ÀûÀº Á߳뵿(?)ÀÌ ¼ö¹ÝµÇ¾î¾ß ÇÑ´Ù. 5) ±âŸ ¸ðµå1) kHTTPd is ¸ÞÀμ­¹ö, "Apache" º¸Á¶¼­¹ö, serverport -> 80 clientport -> 8080 (or whatever) ¸ðµå2) kHTTPd º¸Á¶¼­¹ö, "Apache" ¸ÞÀμ­¹ö, serverport -> 8080 (or whatever) clientport -> 80 ¸ðµå1ÀÇ °æ¿ì´Â kHTTPd°¡ ¸ÞÀμ­¹ö°¡ µÇ¹Ç·Î ¾ÆÆÄÄ¡ ¼³Á¤ÆÄÀÏ¿¡¼­´Â, - port 8080 - UseCannonicalName Off - ¸ðµç °¡»óÈ£½ºÆ® ¼½¼Ç¿¡ ":8080" Ãß°¡ À¸·Î ¼öÁ¤ ¶Ç´Â Ãß°¡ÇØ ÁÖ¾î¾ß ÇÑ´Ù. ÁÖÀÇ) ¸¸¾à, UseCannonicalName OnÀ¸·Î ¼³Á¤ÇÏ¸é ¾ÆÆÄÄ¡´Â ¼³Á¤ÇÑ Æ÷Æ®(8080)¸¦ ÂüÁ¶Çؼ­ URLÀ» À籸¼ºÇϹǷΠÁ¤ÀûÀÎ ÆäÀÌÁö´Â kHTTPd·Î ³Ñ¾î°¡Áö ¾Ê´Â´Ù. µû¶ó¼­ ´ç¿¬ÀÌ ÀÌ ±â´ÉÀ» Off Çسõ¾Æ¾ß ÇÔ. ÀåÁ¡ : Ưº°ÇÏ°Ô HTML Äڵ带 ¼öÁ¤¾øÀÌ Á¤ÀûÀÎ ÆäÀÌÁö´Â Á¶°ÇÀÌ ¸¸Á·ÇÑ´Ù¸é ¸ðµÎ KHTTPd°¡ ºü¸£°Ô Á¦°øÇÒ °ÍÀÌ´Ù. ºÒÇÊ¿äÇÑ Á߳뵿(?)ÀÌ ¾øÀ½. ^.^ ´ÜÁ¡ : ¿ª½Ã °¡»ó È£½ºÆ®¸¦ Áö¿øÇÏÁö ¾ÊÀ¸¹Ç·Î ¸ÞÀÎ DocumentRoot ¿Ü´Â À¯¸í¹«½ÇÇÏ´Ù. Áï °¡»óÈ£½ºÆ®·Î À¥ÆäÀÌÁö¸¦ Á¦°øÇÑ´Ù¸é, ¸ðµÎ ´ÙÀ½°ú °°Àº URLÀÌ ÇÊ¿äÇÒ °ÍÀÌ´Ù. http://www.maindomain.com/ http://www.customer1.com:8080/ http://www.customer2.com:8080/ http://www.customer2.com:8080/ Á¶¾ð : °¡»ó È£½ºÆ®·Î ¿î¿µµÇ´Â ÆäÀÌÁö°¡ °ÅÀÇ ¾ø°Å³ª ºñ±³Àû Á¤ÀûÀÎ ÆäÀÌÁö°¡ ¸¹Àº °æ¿ì¿¡ À¯¸®ÇÏ´Ù. ¸ðµå2ÀÇ °æ¿ìµµ »ý°¢ÇØ º¸ÀÚ. ÀÌ °æ¿ì´Â kHTTPd°¡ º¸Á¶¼­¹öÀÌ°í ¾ÆÆÄÄ¡°¡ ¸ÞÀμ­¹öÀ̹ǷΠº¸Á¶¼­¹ö·Î¼­ÀÇ ¿ªÇÒÀ» ¹Ì¸® °áÁ¤ÇؾßÇÑ´Ù. ¿¹¸¦ µé¸é Á¤ÀûÀÎ ÆäÀÌÁö¸¸ kHTTPd°¡ Á¦°øÇϵµ·Ï ¾ÆÆÄÄ¡³ª HTML¿¡¼­ ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÕ´Ï´Ù. ÀåÁ¡ : À¥ Ç¥ÁØ Æ÷Æ®ÀÎ 80¹øÀ» ¾ÆÆÄÄ¡°¡ »ç¿ëÇϹǷΠ°¡»óÈ£½ºÆ® ¿î¿µÀº ¿¹Àü ±×´ë·Î ¿î¿µÇÒ ¼ö ÀÖ´Ù. ´ÜÁ¡ : kHTTPd°¡ º¸Á¶¼­¹öÀ̹ǷΠÁ¤ÀûÀÎ À¥ÆäÀÌÁö´Â ¸ðµÎ kHTTPd°¡ Á¦°øÇϵµ·Ï °­Á¦Àû(?) À¸·Î ¸µÅ© ¶Ç´Â HTML Äڵ带 ¼öÁ¤ÇØ Áà¾ß ÇÏ´Â Á߳뵿(?)ÀÌ ÀÖ´Ù. Á¶¾ð : °¡»ó È£½ºÆ®·Î ¿î¿µµÇ´Â ÆäÀÌÁö°¡ ¸¹°Å³ª, ºñ±³Àû °£´ÜÇÏ°Ô HTMLÀ» ¼öÁ¤Çؼ­ Á¤ÀûÀÎ ÆäÀÌÁö¸¦ kHTTPd°¡ ¼­ºñ½ºÇÒ ¼ö ÀÖ´Â Á¶°Ç¿¡ Àû´çÇÏ´Ù.(ÇÊÀÚ´Â ÀÌ ¹æ¹ýÀ» Àû¿ë) ÀÌ ¹æ¹ýÀ» »ç¿ëÇϱâ À§Çؼ­´Â ´ÙÀ½ ÀýÀÇ [ÆÁ]À» Âü°í·Î À¥ ÆäÀÌÁö¿Í ¾ÆÆÄÄ¡ ¼³Á¤ÆÄÀÏ À» Á¶±Ý ¼öÁ¤ÇØ ÁÖ½Ã±æ ¹Ù¶ø´Ï´Ù. Âü°í·Î ÇÊÀÚ´Â kHTTPd(8080)¸¦ ¾ÆÆÄÄ¡(80)ÀÇ º¸Á¶ À¥¼­¹ö·Î ¼³Á¤ÇÏ¿© ¿î¿µÇÏ°í ÀÖ½À´Ï´Ù. 4-2. [ÆÁ] PHP ÇÔ¼ö ÀÌ¿ë ÀÌ ÆÁÀº kHTTPd¸¦ ¾ÆÆÄÄ¡ÀÇ º¸Á¶ ¼­¹ö·Î È°¿ëÇϱâ À§Çؼ­ ¾ÆÆÄÄ¡ Â÷¿ø¿¡¼­ Á¤ÀûÀÎ ÆäÀÌÁö ¸¦ ¸ðµÎ kHTTPd·Î Àü´ÞÇϱâ À§ÇÑ ÆÁÀÔ´Ï´Ù. Áï, µ¿ÀûÀÎ ÆäÀÌÁöÀÎ PHP ÆäÀÌÁö¿¡¼­ Á¤ÀûÀ¸·Î ¸µÅ© ¶Ç´Â ·ÎµùÇÒ ³»¿ëÀ» ¸ðµÎ kHTTPd¸¦ ÀÌ¿ëÇؼ­ ºü¸£°Ô ½ÇÇàÇϱâ À§ÇÔÀÔ´Ï´Ù. ¶ÇÇÑ PHP ÆäÀÌÁö¿¡¼­ ºñ±³Àû ½±°Ô ¾Æ·¡ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Â Á¶°ÇÀÌ¸é ´õ¿í ÁÁ½À´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é Á߳뵿(?)ÀÌ ¼ö¹Ý.....^.^ ¾ÆÆÄÄ¡°¡ 80 Æ÷Æ®·Î ¿î¿µµÉ °æ¿ì : : ¾ÆÆÄÄ¡°¡ ½ÇÇà : kHTTPd°¡ ½ÇÇà Áï ÀÌ ÆÁÀº, PHP¸¦ ÀÌ¿ëÇؼ­ ÀüÀÚÀÇ °æ¿ì¸¦ ¸ðµÎ ÈÄÀÚÀÇ °æ¿ì·Î ¸µÅ©Çϱâ À§ÇÔÀ̸ç, ±âÁ¸ÀÇ PHP¿¡ A ű׳ª IMG ű׸¦ ¸ðµÎ PHP ÇÔ¼ö·Î ¸¸µé¾î »ç¿ëÇßÀ» °æ¿ì¿¡ À¯¿ëÇÑ °æ¿ìÀÔ´Ï´Ù. ±×·¸Áö ¸øÇÒ °æ¿ì¿¡´Â ÀÌ ÆÁÀº ¹«¿ëÁö¹°ÀÌ¸ç ¸ðµÎ A ÅÂ±×¿Í IMG ű׸¦ ¼Õ¼ö ¼öÀÛ¾÷ÇØ¾ß ÇÕ´Ï´Ù.....T.T ----------------------------------------------------------------------------------- // kHTTPd 8080 Æ÷Æ® »ç¿ë function GET_KHTTPD($port="8080") { $serv = "123.123.123.123"; // ¸ÞÀμ­¹ö IP ÁÖ¼Ò³ª È£½ºÆ® À̸§À¸·Î ¼³Á¤ //$serv = getenv("HTTP_HOST"); return "http://${serv}:${port}"; } // kHTTPd »ç¿ëÀ» À§ÇÑ ÀÚµ¿ ¸µÅ© ÇÔ¼ö // // Áï, URLÀ» ^/(.+)·Î ½ÃÀÛÇÏ´Â Á¤ÀûÀÎ ÆäÀÌÁö·Î ÀÚµ¿ ¸µÅ©ÇØ ÁÝ´Ï´Ù. // ÇÏ·íµ¿¾È Çì¸Þ¸é¼­ ÀÌ ÇÔ¼ö¸¦ ¸¸µé¾ú½À´Ï´Ù.(T.T).. // ¿ö³« Á¦È¨ÀÌ XÆÇÀÌ¶ó¼­ ¸ðµÎ Àû¿ë½Ãų·Á°í ÇÏ´Ï...ÂÁ // case "$link": ´ÙÀ½°ú °°Àº °æ¿ì¿¡ ¸ðµÎ ÇØ´çµÊ // (./)foobar.(gif|jpg|txt|html|tar|gz|Z|zip) // (./)foobar/foobar.(gif|jpg|txt|html|tar|gz|Z|zip) // (./)foobar/ // (./)/ // (./)/foobar/ // (./)/foobar/foobar.(gif|jpg|txt|html|tar|gz|Z|zip) // --- // (./)foobar Çü½ÄÀÇ ÆÄÀÏÀÌ ¾Æ´Ñ µð·ºÅ丮¿Í http:// ÀÎ °æ¿ì´Â Á¦¿ÜµÇ¾úÀ½ // function GET_LINK($link) { // $link °ªÀÌ http:// ½ÃÀÛÇÏÁö ¾Ê°í gif/jpg/txt/html ·Î ³¡³­ °æ¿ì, // Áï Á¤ÀûÀÎ ÆÄÀϸ¸ ¿äûÇÒ °æ¿ì if(!eregi("^(http|ftp)://(.+)",$link)) { // $baseurlÀº ½ÃÀÛÀº "/", ¸¶Áö¸·Àº "/" $baseurl = dirname(getenv("SCRIPT_NAME")); if($baseurl != "/") { $baseurl .= "/"; } // Root(/) URL ÀÌ ¾Æ´Ò °æ¿ì "/" Ãß°¡ $kHTTPd = Get_kHTTPd(); // *** ÁÖÀÇ *** // ¸¸¾à È®ÀåÀÚ(?)°¡ html·Î ³¡³­ ÆÄÀϾȿ¡ PHP Äڵ尡 ÀÖ´Ù¸é // ´ÙÀ½ if ¹®¿¡¼­ "html|"À» »èÁ¦¿äÇÔ. // if(eregi("([^?].+)\.(gif|jpg|txt|html|tar|gz|Z|zip|mp3|mpg|avi)$",$link)) { if(eregi("^/(.+)",$link)) { $link = "$kHTTPd"."$link"; // DocumentRoot¸¦ ±âÁØÀ¸·Î »ó´ë°æ·ÎÀÏ °æ¿ì } else { $link = "$kHTTPd"."$baseurl".eregi_replace("^/(.+)$","\\1",$link); } } else if(eregi("^(.*)/$",$link)) { // ³¡ÀÌ "/"À¸·Î ³¡³­ °æ¿ì // index.html/index.txt ÆÄÀÏ Á¸Àç ¿©ºÎ üũ if(ereg("^/(.*)",$link)) { // "/"À¸·Î ½ÃÀÛÇÒ °æ¿ì $baseurl = "$link"; } else { $baseurl .= "$link"; } $basedir = getenv("DOCUMENT_ROOT")."$baseurl"; if(file_exists("${basedir}index.html")) { $link = "$kHTTPd".$baseurl."index.html"; } else if(file_exists("${basedir}index.txt")) { $link = "$kHTTPd".$baseurl."index.txt"; } } } return $link; } // IMG TAG ÇÔ¼ö, ¿¹: $arc = abc.gif // $img_w = $imgsize[0]; // $img_h = $imgsize[1]; // $imgsize[3] = "$imgsize[0] $imgsize[1]"; // $arch´Â "/imgaes/foobar.gif" Çü½ÄÀº DocumentRoot¸¦ ±âÁØÀ¸·Î Àý´ë°æ·Î // function HTML_IMG_SRC($arch,$border="0",$alt="0",$width="0",$height="0",$align="0",$valign="0") { if(!$alt) { $alt = ""; } if($align) { $align = " align=\"$align\""; } else { $align = ""; } if($valign) { $valign = " valign=\"$valign\""; } else { $valign = ""; } $docroot = getenv("DOCUMENT_ROOT"); $imgurl = GET_LINK($arch); // $arch°¡ DocumentRoot¸¦ ±âÁØÀ¸·Î Àý´ë°æ·Î if(!$width && !$height) { if (eregi("^/(.+)$",$arch)) { $imgarch = "$docroot"."$arch"; } else { $imgarch = "$arch"; } $imgsize = @GetImageSize("$imgarch"); } else { $imgsize[3] = "width=\"$width\" height=\"$height\""; } $img_src = "\"$alt\"$align$valign"; return $img_src; } // ÀÚ¹Ù ½ºÅ©¸³Æ® window.status A ÅÂ±× // Function TAG_A($str,$link, $target="0", $winstatus="0") { if($winstatus) { $status = " onMouseOver=\"window.status='$winstatus'; return true\" onMouseOut=\"window.status=''; return true\""; $title = " TITLE=$winstatus"; } // 2001.02.18 ÀÏ Ãß°¡ $link = GET_LINK($link); if($target) { $link = "$str"; } else { $link = "$str"; } return $link; } ------------------------------------------------------------------------------- [»ç¿ë¹ý] ÀÏ¹Ý HTMLÀÏ °æ¿ì : foobar string À§ÀÇ PHP ÇÔ¼ö¸¦ »ç¿ëÇÒ °æ¿ì : ¸ðµç ÀÛ¾÷ÀÌ ³¡³µÀ¸¸é, ¾ÆÆÄÄ¡ ·Î±×ÆÄÀÏÀ» ¸ð´ÏÅ͸µÇϸ鼭 Á÷Á¢ À¥ºê¶ó¿ìÀú·Î Á¤ÀûÀÎ ÆÄÀϵéÀ» ¿äûÇØ º½À¸·Î½á ·Î±× ÆÄÀÏ¿¡ ±â·ÏÇÏ´ÂÁö ±â·ÏÇÏÁö ¾ÊÀºÁö È®ÀÎÇØ º¸½Ã±æ ¹Ù¶ø´Ï´Ù. ¸¸¾à ¾ÆÆÄÄ¡ ·Î±×ÆÄÀÏ¿¡ ¹æ±Ý È£ÃâÇÑ Á¤ÀûÀÎ ÆäÀÌÁö(À̹ÌÁö³ª txt ÆÄÀÏ) Á¢±Ù ±â·ÏÀÌ ÀÖ´Ù¸é kHTTPd·Î Àü´ÞÇÏÁö ¾Ê°í ¾ÆÆÄÄ¡ ¼öÁØ¿¡¼­ ½ÇÇàÇÑ °æ¿ì¹Ç·Î óÀ½ºÎÅÍ ÀÛ¾÷À» ´Ù½ÃÇØ¾ß ÇÑ´Ù........(¹º°¡ À߸øµÇ¾î ÀÖ´Ù.) ¿¹: # tail -f /usr/local/apache/logs/access_log 4-3. [ÆÁ] ¾ÆÆÄÄ¡ rewrite ¸ðµâ ÀÌ¿ë ÀÌ ¹æ¹ýÀº kHTTPd¸¦ º¸Á¶ À¥¼­¹ö·Î ÀÌ¿ëÇÏ°í ¾ÆÆÄÄ¡´Â 80 Æ÷Æ® Áï ¸ÞÀμ­¹ö·Î ¿î¿µÇÒ °æ¿ì¿¡ ÇØ´çµÈ ³»¿ëÀÔ´Ï´Ù. Áï ¾ÆÆÄÄ¡¿¡¼­ rewrite ¸ðµâÀ» ÀÌ¿ëÇؼ­ Á¤ÀûÀÎ ³»¿ëÀº ¸ðµÎ kHTTPd·Î º¸³»±â À§ÇÔÀÌ ±× ¸ñÀûÀÔ´Ï´Ù. ¾ÆÆÄÄ¡ rewrite ¸ðµâÀ» »ç¿ë°¡´ÉÇÑÁö ¸ÕÀú È®ÀÎÇØ º¸ÀÚ. # httpd -l (¶Ç´Â # /usr/local/apache/bin/httpd -l) Compiled-in modules: http_core.c mod_env.c mod_log_config.c mod_mime.c mod_negotiation.c mod_status.c mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_asis.c mod_imap.c mod_actions.c mod_userdir.c mod_alias.c mod_rewrite.c <---------------È®ÀλçÇ× mod_access.c mod_auth.c mod_setenvif.c mod_php.c # ¶Ç´Â RPMÀ¸·Î ¼³Ä¡Çß´Ù¸é, ¾ÆÆÄÄ¡ ¼³Á¤ ÆÄÀÏ(httpd.conf)¿¡ ... LoadModule rewrite_module modules/mod_rewrite.so ... AddModule mod_rewrite.c ... ºÎºÐÀÌ ÀÖ´ÂÁö È®ÀÎÇÑ´Ù. ¸¸¾à rewrite ¸ðµâÀ» »ç¿ëÇÒ ¼ö ¾ø´Â °æ¿ì¶ó¸é ´ÙÀ½°ú °°Àº ¹æ¹ýÀ¸·Î ¾ÆÆÄÄ¡¿¡ rewrite ¸ðµâÀ» Ãß°¡ÇØ Áà¾ß ÇÑ´Ù. [DSO ¸ðµâ·Î Á÷Á¡ ÄÄÆÄÀÏ ÇÒ °æ¿ì] ¹æ¹ý1) # apxs -i -a -c /any/path/to/src/modules/standard/mod_rewrite.c apxs À¯Æ¿¸®Æ¼ »ç¿ëÇÒ °æ¿ì ¹æ¹ý2) --enable-module=rewrite --enable-shared=rewrite rewrite¸¦ enable ½ÃÅ°°í DSO ¸ðµâ·Î enable ½ÃÅ´ ¹æ¹ý3) --enable-module=all --enable-shared=rewrite ¸ðµç ¸ðµâÀ» enable ½ÃÅ°°í mod_rewrite¸¸ DSO ¹æ½ÄÀ¸·Î Ãß°¡ ¹æ¹ý4) --enable-module=all --enable-shared=max ¸ðµç ¸ðµâÀ» enable ½ÃÅ°°í httpd_core¿Í mod_so¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö ¸ðµâ(mod_rewrite°¡ Æ÷ÇÔµÊ)À» DSO ¹æ½ÄÀ¸·Î Ãß°¡ ¹æ¹ý5) --enable-module=rewrite --enable-shared=max mod_rewrite¸¦ enable ½ÃÅ°°í ³ª¸ÓÁö enableµÈ ¸ðµâ°ú ÇÔ²² DSO ¹æ½ÄÀ¸·Î Ãß°¡ ¹æ¹ý6) --enable-shared=remain ¾ÆÁ÷ enableµÇ¾î ÀÖÁö ¾ÊÀº mod_rewrite ¸ðµâÀ» Æ÷ÇÔÇÑ ³ª¸ÓÁö ±âº» enable ¸ðµâÀ» enable½ÃÅ°°í httpd_core¿Í mod_so¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö ¸ðµâ(mod_rewrite °¡ Æ÷ÇÔµÊ) À» DSO ¹æ½ÄÀ¸·Î Ãß°¡ Âü°í) --enabl/disable-shared=max ¿É¼Ç ¹Ù·Î ÀÌÀü ¿É¼Ç¿¡¼­ enable µÇ¾î ÀÖ´Â ¸ðµâ¿¡ ´ëÇؼ­¸¸ DSO ¹æ½ÄÀ¸·Î enable/disable. --enable-shared=remain ¿É¼Ç ¹Ù·Î ÀÌÀü ¿É¼Ç¿¡¼­ enable µÇ¾î ÀÖÁö ¾ÊÀº ¸ðµâÀ» enable ½ÃÅ°°í ÀÌ ¸ðµâ¿¡ ´ëÇؼ­¸¸ DSO ¹æ½ÄÀ¸·Î enable. [Á¤ÀûÀ¸·Î Á÷Á¡ ÄÄÆÄÀÏ ÇÒ °æ¿ì] --enable-module=rewrite ÀÌÁ¦ ¾ÆÆÄÄ¡¿¡¼­ rewrite ¸ðµâÀ» »ç¿ë°¡´ÉÇÏ¸é ´ÙÀ½°ú °°ÀÌ µÎ ÁÙ Á¤µµÀÇ ¼³Á¤ ³»¿ëÀÌ ÇÊ¿äÇÒ °ÍÀÔ´Ï´Ù. ------------ httpd.conf --------------------------------------------- # main host ¶Ç´Â °¡»óÈ£½ºÆ® ¼½¼Ç ¾È¿¡ ´ÙÀ½ Ãß°¡ # ## 2001.02.22 For kHTTPd # RewriteEngine on RewriteRule ^/([^?].+)(txt|html|gz|tar|Z|zip|gif|jpg|mp(3|eg|g)|wav|avi|rpm|iso)$ http://www.maindomain.com:8080/$1$2 [R,L] # --------------------------------------------------------------------- ÁÖÀÇ) ¿äûµÇ´Â À¥ÆäÀÌÁö ¾È¿¡ PHP¿Í °°Àº µ¿ÀûÀÎ ½ºÅ©¸³Æ®°¡ ¾ø¾î¾ß ÇÑ´Ù. ¸¸¾à HTML ÆÄÀÏ ¾È¿¡ PHP Äڵ尡 µé¾î ÀÖ´Ù¸é ±× ºÎºÐÀº ¹«½ÃµÇ¾î ¾Æ¹«°Íµµ Ç¥½ÃµÇÁö ¾Ê´Â´Ù. Á¦´ë·Î rewrite ¸ðµâÀÌ ÀÛµ¿ÇÏ´ÂÁö Å×½ºÆ®ÇØ º»´Ù. ¾ÆÆÄÄ¡¸¦ Àç°¡µ¿ÇÏ°í, URL¿¡ http://www.maindomain.com/any/path/to/foobar.txt À» ¿äûÇϸé http://www.maindomain.com:8080/any/path/to/foobar.txt À¸·Î redirect µÉ °ÍÀÌ´Ù. ÁÖÀÇ) ¾ÕÀÇ °æ¿ìó·³ Á÷Á¢ ¾ÆÆÄÄ¡ 80 Æ÷Æ®¿¡ URL ¿äûÀÌ ÀÖ¾ú±â ¶§¹®¿¡ ¾ÆÆÄÄ¡ log ÆÄÀÏ¿¡´Â ±× Á¢±Ù ±â·ÏÀÌ ³²¾Æ ÀÖ½À´Ï´Ù. ¹°·Ð °ð¹Ù·Î kHTTPd·Î Àü´ÞµÇ±â´Â ÇÏÁö¸¸... Âü°í) rewrite ¸ðµâ¿¡ °üÇÑ Á¤º¸ - ¾ÆÆÄÄ¡ Á¦°ø ¹®¼­ - Module mod_rewrite URL Rewriting Engine : http://www.apache.org/docs/mod/mod_rewrite.html - ¾ÆÆÄÄ¡ Á¦°ø ¹®¼­ - Rewriting Guide : http://www.apache.org/docs/misc/rewriteguide.html - ¾ÆÆÄÄ¡ Á¦°ø ¹®¼­ - Dynamically configured mass virtual hosting : http://www.apache.org/docs/vhosts/mass.html - A Users Guide to URL Rewriting with the Apache Webserver : Ralf S. Engelschall http://www.engelschall.com/pw/apache/rewriteguide/ - URL manipulation with Apache Forwarded : Ralf S. Engelschall, Christian Reiber http://www.heise.de/ix/artikel/E/9612149/ 5. °£´ÜÇÑ ¼º´É Å×½ºÆ® Å×½ºÆ® ȯ°æÀÌ °øÆòÇÏÁö ¾Ê¾Æ(Á¦°¡ ÀÖ´Â ³×Æ®¿öÅ© ȯ°æ), °´°üÀûÀÎ Å×½ºÆ®°¡ µÇÁú ¾Ê±â ¶§¹®¿¡ ÀÌ ºÎºÐÀº ±â·ÏÇÏÁö ¸øÇß½À´Ï´Ù(¿ÀÇØÀÇ ¼ÒÁö°¡ ¸¹À» µí Çؼ­...). Á÷Á¢ ab(ApacheBench)¿Í Lynx·Î °¢°¢ÀÇ À¥¼­¹ö¿¡¼­ ±¸µ¿µÇ´Â Á¤ÀûÀÎ ÆäÀÌÁö¸¦ ¿äûÇؼ­ ½Ã°£À» Àç¾îº¸½Ã±æ ¹Ù¶ø´Ï´Ù. Âü°í) Å×½ºÆ® ±âÁØ - °°Àº URL/Å©±âÀÇ ÆÄÀÏ. - ¾ÆÆÄÄ¡¿¡¼­ ·Î±×±â·ÏÀ» ÇÏÁö ¾Êµµ·Ï ¼³Á¤. - °°Àº Remote host¿¡¼­ Å×½ºÆ®. - ¼Ò·Î Æ÷Æ®¸¦ ¹Ù²Ù¾î °¡¸é¼­ °°Àº Æ÷Æ®¿¡ ´ëÇؼ­ Å×½ºÆ®. - ±âŸ °¡´ÉÇÏ´Ù¸é °°Àº Á¶°Ç¿¡¼­. - ab(¿¹:/usr/local/apache/bin/ab)·Î Å×½ºÆ®ÇÒ °æ¿ì (abÀÇ »ç¿ë¹ýÀº ab¸¦ ÀÔ·ÂÇϼ¼¿ä.) »ç¿ëÇü½Ä : ab -n ¿äûȸ¼ö ¿äûURL # ab -n 100 http://www.domain.com/any/path/to/foobar.txt Âü°í·Î °á°ú¸¦ HTML·Î Ãâ·ÂÇÏ°íÀÚ ÇÑ´Ù¸é, # ab -n -w 100 http://www.domain.com/any/path/to/foobar.txt > result.html - Lynx¸¦ ÀÌ¿ëÇÒ °æ¿ì # time lynx --sourec http://www.domain.com/any/path/to/foobar.txt >/dev/null ½© ½ºÅ©¸³Æ® ÀÛ¼ºÀÌ °¡´ÉÇÏ´Ù¸é ½ºÅ©¸³Æ®·Î ÀÛ¼ºÇؼ­ Å×½ºÆ®ÇØ º¸½Ã±æ... (Âü°í·Î ÇÊÀÚ°¡ ¿î¿µÇÏ´Â ¸®´ª½ºÀÇ ¾à 15KB HTML ÆÄÀÏ ¿äû½Ã Localhost¿¡¼­ Àü¼Û ¼Óµµ°¡ ¾à 6¹è Â÷ÀÌ°¡ ³µ´Ù....¹°·Ð ¾ÆÆÄÄ¡ ·Î±×±â·ÏÀº ÇÏÁö ¾ÊÀº »óÅ¿¡¼­). ¹®Á¦´Â ³×Æ®¿öÅ© ´ë¿ªÆø!!! 6. ¸¶Ä¡¸ç (......................).+ 7. Áú¹®°ú ´äº¯ [Áú¹®] kHTTPdµµ ÀÚü ·Î±×¸¦ ±â·ÏÇÕ´Ï´Ù. [´äº¯] ÇöÀç 0.1.6¹öÀü±îÁö´Â ±â·ÏÇÏÁö ¾Ê½À´Ï´Ù. ´Ù¸¸ 0.1.6c ¹öÀüºÎÅÍ´Â ·Î±ëÇÏ´Ù·Ï µÇ¾îÀÖÀ¸³ª À̶§´Â khttpdlog ¿Í °°Àº µ¥¸óÀÌ ÇÊ¿äÇÕ´Ï´Ù. http://www.fenrus.demon.nl/ À» ¹æ¹®Çϸé sample khttpdlog µ¥¸óÀ» ãÀ» ¼ö ÀÖÀ» °Ì´Ï´Ù. [Áú¹®] kHTTPd¸¦ ²À 8080 Æ÷Æ®·Î ¼³Á¤ÇؾßÇմϱî? [´äº¯] ²À 8080 Æ÷Æ®·Î ¼³Á¤ÇÏÁö ¾Ê¾Æµµ µË´Ï´Ù. 8000¹ø Æ÷Æ®µµ ÃßõÇÒ ¸¸ ÇÕ´Ï´Ù. [Áú¹®] kHTTPdÀÇ 8080Æ÷Æ®·Î Á¢±ÙÇß´Ù´Â ±â·ÏÀº ¾îµð¿¡¼­ º¼ ¼ö ÀÖ½À´Ï±î? [´äº¯] /var/log/messages ÆÄÀÏÀ» ¿­¾îº¸¸é, .... webcache connection attempt from 211.xxx.xxx.xxx ¶ó´Â ±â·ÏÀ» º¼ ¼ö ÀÖÀ» °Ì´Ï´Ù. Áï, webcache¶ó´Â ¼­ºñ½ºÀ̸§À» /etc/services ÆÄÀÏ¿¡¼­ 8080 Æ÷Æ®·Î ¼³Á¤Ç߱⠶§¹®ÀÔ´Ï´Ù. ¸¸¾à, ´ÙÀ½°ú °°ÀÌ /etc/services ÆÄÀÏÀ» ÆíÁýÇÏ°í, khttpd 8080/tcp # /etc/rc.d/init.d/network restart ³×Æ®¿öÅ©¸¦ Àç ½ÃÀÛÇÑ ´ÙÀ½, ´Ù½Ã URL¿¡ ¿äûÇϸé, .... khttpd connection attempt from 211.xxx.xxx.xxx ÀÇ ±â·ÏÀ» È®ÀÎÇÒ ¼ö ÀÖÀ» °Ì´Ï´Ù. 8. ºÎ·Ï - kHTTPd Á¦¾î ½©½ºÅ©¸³Æ® ------------------------------------------------------------------------ #!/bin/sh ## ## 2001.02.18 Chilbong, Kim ## static kHTTPd, NOT Modules ## Default setting : ## "Apache" is main webserver, kHTTPd is assistant ## Apache Port($set_cport) : 80 ## kHTTPd Port($set_sport) : 8080 ## kHTTPd Logging($set_loggging) : 0(no) ## ## ## How to using ## 1) this file name is 'khttpd'. ## 2) chmod 704 khttpd ; chown root.root khttpd ## 3) cp khttpd /usr/local/bin/ (or /usr/sbin/ or include in $PATH) ## 4) you should be 'apache shoutdown' before khttpd starting. ## 5) khttpd start : you type 'khttpd start' ## 6) khttpd stop : you type 'khttpd stop' ## 7) khttpd status : you type 'khttpd status' ## 8) more help : you type 'khttpd' or 'khttpd --help' ## # Require setting !!!!!!!! # hub !!! not good # apache_htdocs="/home/wwwhome/linuxchannel.net/newhome" khttpdlog="/usr/local/bin/khttpdlog" # # end setting khttpd_help() { echo "Usage... khttpd [start|stop|status]" echo " khttpd start [documentroot] [port] [1(logging yes)|0(logging no)]" exit 0 } khttpd_status() { echo " + kHTTPd Port : $1" echo " + kHTTPd DocumentRoot : $2" echo " + Another Server Port : $3" echo " + logging [ 0=no, 1=yes ] : $4" } kill_khttpdlog() { if [ "$1" -ge "1" ] ; then killall khttpdlog >/dev/null 2>/dev/null fi } khttpd="/proc/sys/net/khttpd" serverport="${khttpd}/serverport" clientport="${khttpd}/clientport" threads="${khttpd}/threads" documentroot="${khttpd}/documentroot" dynamic="${khttpd}/dynamic" start="${khttpd}/start" stop="${khttpd}/stop" logging="${khttpd}/logging" START=$(cat $start 2>/dev/null) STOP=$(cat $stop 2>/dev/null) DOCROOT=$(cat $documentroot 2>/dev/null) SPORT=$(cat $serverport 2>/dev/null) CPORT=$(cat $clientport 2>/dev/null) LOGGING=$(cat $logging 2>/dev/null) RUNLOGGING=`ps -ef | grep khttpdlog | grep -v grep | wc -l` if [ "$START" = "1" -a $STOP = "0" ] ; then khttpd_run="1" fi if [ "$1" = "" ] ; then khttpd_help fi case "$1" in start) if [ "$khttpd_run" = "1" ] ; then echo "kHTTPd RUNNING !!! please, khttpd stop" exit 0 else # $2, kHTTPd DocumentRoot if [ "$2" = "" ] ; then set_docroot="$apache_htdocs" else set_docroot="$2" fi # $3, kHTTPd Port default 8080 port if [ "$3" = "" -o "$3" = "8080" ] ; then set_sport="8080" set_cport="80" else set_sport="$3" set_cport="8080" fi # Notes **************************************************** # 1) This version works ONLY for kHTTPd 0.1.6c # 2) You must configure kHTTPd to log BEFORE STARTING it # 3) The logging-daemon must be running BEFORE STARTING kHTTPd # from http://www.fenrus.demon.nl/ # $4, if not given, default set logging "0(no)" # if [ -x $khttpdlog ] ; then if [ "$4" = "1" ] ; then # check khttpdlog #if [ "$RUNLOGGING" -ge "1" -a $LOGGING = "0" ] ; then # killall khttpdlog 2>/dev/null #fi # force down khttpdlog kill_khttpdlog "$RUNLOGGING" # start khttpdlog, see /var/log/khttpd.log echo 1 > $logging $khttpdlog >/dev/null 2>/dev/null & else echo 0 > $logging fi else echo 0 > $logging fi echo $set_sport > $serverport echo $set_cport > $clientport echo 2 > $threads echo "$set_docroot" > $documentroot echo php3 > $dynamic echo php > $dynamic sleep 1 echo 0 > $stop sleep 1 echo 1 > $start fi ;; stop) echo 1 > $stop sleep 1 echo 0 > $start sleep 1 kill_khttpdlog "$RUNLOGGING" ;; status) if [ "$khttpd_run" = "1" ] ; then echo " kHTTPd RUNNING !!!" khttpd_status "$SPORT" "$DOCROOT" "$CPORT" "$LOGGING" else echo "kHTTPd NOT running !!!" fi ;; *) khttpd_help ;; esac exit 0 ------------------------------------------------------------------------