´ÙÀ½ ÀÌÀü Â÷·Ê

8. °¡»óÀÇ À¥

8.1 Virtuald¿Í ½ÇÇàÇϱâ

±ÇÇÏÁö ¾ÊÀ½!(Not recommended)

¾ÆÆÄÄ¡´Â ±âº»ÀûÀ¸·Î °¡»óÀÇ µµ¸ÞÀÎÀ» À§ÇÑ Áö¿øÀ» ÇØÁØ´Ù. ¾ÆÆÄÄ¡´Â ³»°¡ ³»ºÎÀÇ °¡»ó µµ¸ÞÀÎ ±âÀÛÀ» »ç¿ëÇÏ´Â °ÍÀ» ±ÇÇÏ´Â À¯ÀÏÇÑ ÇÁ·Î±×·¥ÀÌ´Ù. inetd¸¦ ÅëÇؼ­ ¾î¶² ÇÁ·Î±×·¥ÀÌ ½ÇÇàµÇ´Â °ÍÀº ¸¹Àº ´ë°¡¸¦ ÇÊ¿ä·Î Çϸç, ÇÁ·Î±×·¥ÀÌ ½ÃÀÛÇϱâ À§Çؼ­´Â Ç×»ó inetd°¡ ½ÃÀ۵Ǿî¾ß ÇÑ´Ù´Â ´ÜÁ¡ÀÌ ÀÖ´Ù. ÀÌ·± °á°ú·Î ¹ÝÀÀ ½Ã°£ÀÌ ´À·ÁÁú °ÍÀε¥, ´Ù¸¥ ³×Æ®¿öÅ© ¼­ºñ½º¿¡¼­´Â ÀÌ·± ´À·ÁÁüÀÌ °ßµô¸¸ ÇÏÁö¸¸ À¥ ¼­ºñ½º¿¡¼­´Â ±×·¸Áö ¾ÊÀ» °ÍÀÌ´Ù. ¾ÆÆÄÄ¡´Â ¶ÇÇÑ ³Ê¹« ¸¹Àº ¿äûÀÌ µé¾î¿À´Â °æ¿ì Á¦¾î¸¦ ÇÒ ¼ö ÀÖ´Â ±â´ÉÀ» °¡Áö°í Àִµ¥, ÀÌ ±â´ÉÀº Å©Áö ¾ÊÀº ±Ô¸ðÀÇ »çÀÌÆ®¿¡¼­µµ Áß¿äÇÑ ¹®Á¦°¡ µÉ ¼ö ÀÖ´Ù.

°£´ÜÈ÷ ¸»Çϸé, ¾ÆÆÄÄ¡ ¼­¹ö¸¦ virtuald¿Í ÇÔ²² »ç¿ëÇÏ¿© °¡»ó ½Ã½ºÅÛÀ» ±¸ÃàÇÏ´Â °ÍÀº Á¤¸» ¾ÈÁÁÀº »ý°¢ÀÌ´Ù. virtuald°¡ ÁöÇâÇÏ´Â °ÍÀº Á¦°øÇÏ°íÀÚ ÇÏ´Â ¼­ºñ½º°¡ ³»ºÎ¿¡¼­ °¡»ó °ø°£¿¡ ´ëÇÑ ¸¸Á·½º·¯¿î Áö¿øÀ» ÇÏÁö ¾ÊÀ» °æ¿ì¿¡ ºÎÁ·ÇÑ ºÎºÐÀ» ä¿ì´Â ÀÏÀÌ´Ù. virtuald°¡ ÀÌ¹Ì ¿Ïº®ÇÏ°Ô °¡»ó ½Ã½ºÅÛÀ» Áö¿øÇÏ´Â ÁÁÀº Äڵ带 ´ëüÇϱâ À§ÇÑ °ÍÀº ¾Æ´Ï´Ù.

¹°·Ð À§ÀÇ Ãæ°íµµ ²À ±×·¸°³ ÇÏ°í ¸»¸®¶ó »ý°¢ÇÏ´Â ¹«¸ðÇÑ »ç¶÷µé¿¡°Ô´Â º° È¿¿ëÀÌ ¾øÀ» °ÍÀÌÁö¸¸.

Inetd

/etc/inetd.conf ¸¦ ÆíÁýÇ϶ó.

vi /etc/inetd.conf # Add this line
www stream tcp nowait www /usr/local/bin/virtuald \
        virtuald /virtual/conf.www httpd -f /var/www/conf/httpd.conf

Httpd.conf

/var/www/conf/httpd.conf¸¦ ÆíÁýÇ϶ó.

vi /var/www/conf/httpd.conf # Or wherever you put the Apache config files
It should say:
ServerType standalone

Replace it with:
ServerType inetd

¼³Á¤

±×¸®°í´Â ¾ÆÆÄÄ¡ ¼­¹öÀ» ÀϹÝÀûÀ¸·Î ¼³Á¤ÇÏ´Â °úÁ¤À» ¼öÇàÇÑ´Ù.

Httpd.init

inetd¸¦ ÅëÇؼ­ ¾ÆÆÄÄ¡°¡ ½ÇÇàµÉ ¶§¿¡´Â httpd.initÀº ÇÊ¿ä¾ø´Ù.

8.2 Apache VirtualHost¿Í °°ÀÌ ½ÇÇàÇϱâ

¾ÆÆÄÄ¡´Â ¼¼ °³ÀÇ ¼³Á¤ ÆÄÀÏ - access.conf , httpd.conf , srm.confÀ» °¡Áø´Ù. ¾ÆÆÄÄ¡ÀÇ »õ·Î¿î ¹öÀüÀº ¼³Á¤ ÆÄÀÏÀÌ ¼¼ °³ÀÏ ÇÊ¿ä´Â ¾ø´Ù. ÇÏÁö¸¸, ¼¼ °³ÀÇ ¼³Á¤ÆÄÀÏ·Î ³ª´©¾îÁ® ÀÖ´Â °ÍÀÌ ÈξÀ °ü¸®ÇÏ°í ¼³Á¤ÇϱⰡ ½±´Ù°í »ý°¢µÇ±â ¶§¹®¿¡ ÀÌ ÇÏ¿ìÅõ ¹®¼­¿¡¼­´Â ÀÌ ½ºÅ¸ÀÏÀ» ±âÁØÀ¸·Î ¼³¸íÇÏ°Ú´Ù.

Access.conf

ÀÌ ¼³Á¤ÆÄÀÏÀº À¥ µð·ºÅ丮 ±¸Á¶¿¡¼­ Á¢±ÙÀ» ÅëÁ¦Çϴµ¥ »ç¿ëµÈ´Ù. ¿©±â °¢°¢ÀÇ µµ¸ÞÀο¡ ¾î¶»°Ô ¼­·Î ´Ù¸¥ ¿É¼ÇÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´ÂÁö¸¦ º¸¿©ÁÖ´Â ¿¹Á¦ ¼³Á¤ÆÄÀÏÀÌ ÀÖ´Ù.

# /var/www/conf/access.conf: Global access configuration

# Options are inherited from the parent directory
# Set the main directory with default options
<Directory />
AllowOverride None
Options Indexes
</Directory>

# Give one domain a passwd protected directory
<Directory /virtual/domain1.com/var/www/html/priv>
AuthUserFile /var/www/passwd/domain1.com-priv
AuthGroupFile /var/www/passwd/domain1.com-priv-g
AuthName PRIVSECTION
AuthType Basic
<Limit GET PUT POST>
require valid-user
</Limit>
</Directory>

# Give another domain Server Side Includes
<Directory /virtual/domain2.com/var/www/html>
Options IncludesNOEXEC
</Directory>

Httpd.conf

ÀÌ ¼³Á¤ÆÄÀÏÀº ¾ÆÆÄÄ¡ ¼­¹öÀÇ ÁÖµÈ ¿É¼ÇÀ» °ü¸®ÇÑ´Ù. ¿©±â °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ ¼­·Î ´Ù¸¥ ¿É¼ÇÀ» ¼³Á¤ÇÏ´Â °Í¿¡ ´ëÇÑ ¿¹Á¦ ÆÄÀÏÀÌ ÀÖ´Ù.

# /var/www/conf/httpd.conf: Main server configuration file

# Begin: main conf section

# Needed since not using inetd
ServerType standalone

# Port to run on
Port 80

# Log clients with names vs IP addresses
HostnameLookups on

# User to run server as
User www
Group www

# Where server config, error and log files are
ServerRoot /var/www

# Process Id of server in this file
PidFile /var/run/httpd.pid

# Internal server process info
ScoreBoardFile /var/www/logs/apache_status

# Timeout and KeepAlive options
Timeout 400
KeepAlive 5
KeepAliveTimeout 15

# Number of servers to run
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 30

# End: main conf section

# Begin: virtual host section

# Tell server to accept requests for ip:port
# I have one for each IP needed so you can explicitly ignore certain domains
Listen 10.10.10.129:80
Listen 10.10.10.130:80

# VirtualHost directive allows you to specify another virtual
# domain on your server.  Most Apache options can be specified
# within this section.
<VirtualHost www.domain1.com>

# Mail to this address on errors
ServerAdmin webmaster@domain1.com

# Where documents are kept in the virtual domain
DocumentRoot /virtual/domain1.com/var/www/html

# Name of the server
ServerName www.domain1.com

# Log files Relative to ServerRoot option
ErrorLog logs/domain1.com-error_log
TransferLog logs/domain1.com-access_log
RefererLog logs/domain1.com-referer_log
AgentLog logs/domain1.com-agent_log

# Use CGI scripts in this domain
ScriptAlias /cgi-bin/ /var/www/cgi-bin/domain1.com/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
</VirtualHost>

<VirtualHost www.domain2.com>

# Mail to this address on errors
ServerAdmin webmaster@domain2.com

# Where documents are kept in the virtual domain
DocumentRoot /virtual/domain2.com/var/www/html

# Name of the server
ServerName www.domain2.com

# Log files Relative to ServerRoot option
ErrorLog logs/domain2.com-error_log
TransferLog logs/domain2.com-access_log
RefererLog logs/domain2.com-referer_log
AgentLog logs/domain2.com-agent_log

# No CGI's for this host
</VirtualHost>
# End: virtual host section

Srm.conf

ÀÌ ¼³Á¤ÆÄÀÏÀº ¾î¶² ¿äû¿¡ ´ëÇØ ¼­ºñ½º¸¦ Á¦°øÇÒ °ÍÀÎÁö¿Í ±× Çü½ÄÀÌ ¾î¶»°Ô µÉ °ÍÀÎÁö¿¡ ´ëÇÑ °ÍÀ» Á¶ÀýÇÑ´Ù. °¡»ó µµ¸ÞÀο¡ ´ëÇؼ­ ÀÌ°ÍÀ» ¹Ù²Ü ÇÊ¿ä´Â ¾ø´Ù. ¾ÆÆÄÄ¡¿¡¼­ ±âº»ÀûÀ¸·Î Á¦°øÇÏ´Â ¿¹Á¦ ÆÄÀÏ Çü½Ä ±×´ë·Î °¡»ó ½Ã½ºÅÛ¿¡ Àû¿ëÇصµ ÀÛµ¿ÇÒ °ÍÀÌ´Ù.

Httpd.init

httpd.init ÆÄÀÏ¿¡ ´ëÇؼ­ Ưº°È÷ ÇØÁÙ °ÍÀº ¾ø´Ù. ¾ÆÆÄÄ¡ÀÇ Ç¥ÁØÀûÀÎ ¼³Á¤À» ÀÌ¿ëÇ϶ó.

8.3 ÆÄÀÏ ¼­¼úÀÚ ¿À¹öÇ÷οì(File Descriptor Overflow)

°æ°í

ÀÌ°ÍÀº ¿ÀÁ÷ µ¶¸³Àû(standalone style)ÀÎ ¾ÆÆÄÄ¡ ¼­¹ö¿¡¸¸ ÇØ´çµÈ´Ù. inetd¸¦ ÅëÇؼ­ ¼­¹ö°¡ ½ÇÇàµÉ ¶§¿¡´Â ´Ù¸¥ µµ¸ÞÀΰú ¿¬°üÀÌ ¾ø±â ¶§¹®¿¡ ¸ðµç ÆÄÀÏ ¼­¼úÀÚ Å×À̺íÀ» °®´Â´Ù.

¾ÆÆÄÄ¡ ¼­¹ö°¡ ¿©´Â ¸ðµç ·Î±× ÆÄÀϵéÀº ÇÁ·Î¼¼½º¿¡ ´ëÇÑ ¶Ç´Ù¸¥ ÆÄÀÏ ¼­¼úÀÚ (file descriptor)°¡ µÈ´Ù. ¸®´ª½º¿¡¼­´Â °¢°¢ÀÇ ÇÁ·Î¼¼½º¿¡ ´ëÇؼ­ 256°³ ±îÁö ÆÄÀÏ ±â¼úÀÚ¸¦ °¡Áú ¼ö ÀÖ´Ù´Â Á¦¾àÀÌ ÀÖ´Ù. Áï ¿©·¯°³ÀÇ µµ¸ÞÀÎÀ» »ç¿ëÇÑ´Ù¸é ±¸¸ÕÄñ ¸¹Àº ÆÄÀÏ ±â¼úÀÚµéÀÌ ÇÊ¿äÇÏ°Ô µÈ´Ù. ¸¸¾à ÇϳªÀÇ ¾ÆÆÄÄ¡ ¼­¹ö ÇÁ·Î¼¼½º¿¡¼­ ³Ê¹« ¸¹Àº µµ¸ÞÀÎÀ» ¼³Á¤ÇÏ°í »ç¿ëÇÑ´Ù¸é ÀÌ Å×À̺íÀÌ ³ÑÃij¯(overflow) ¼öµµ ÀÖ´Ù. ÀÌ°ÍÀº ƯÁ¤ÇÑ ·Î±×°¡ ÀÛµ¿ÇÏÁö ¾ÊÀ» ¼öµµ ÀÖÀ¸¸ç, CGI°¡ ½ÇÆÐÇÒ ¼öµµ ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù.

¿©·¯°³ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö

¸¸¾à ÇÑ µµ¸ÞÀο¡ ´ëÇؼ­ ´Ù¼¸°³ÀÇ ÆÄÀÏ ±â¼úÀÚ¸¦ °¡Áö°í ÀÖ´Ù°í °¡Á¤ÇÏ¸é ´ç½ÅÀº ¾ÆÆÄÄ¡ ¼­¹ö¿¡¼­ 50°³ÀÇ µµ¸ÞÀÎÀ» ¾Æ¹« ¹®Á¦¾øÀÌ ½ÇÇà½Ãų ¼ö ÀÖ´Ù. ÇÏÁö¸¸, ¸¸¾à ÀÌ·± »óȲ¿¡¼­ ¹®Á¦°¡ ¹ß»ýÇÑ´Ù¸é /var/www1¿¡ µµ¸ÞÀÎ1-µµ¸ÞÀÎ25 ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö¸¦ ÇÒ´çÇÏ°í, /var/www2¿¡ µµ¸ÞÀÎ26-µµ¸ÞÀÎ50ÀÇ ¾ÆÆÄÄ¡ ¼­¹ö¸¦ ÇÒ´çÇÏ´Â ¹æ½ÄÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº °¢°¢ÀÇ ¼­¹ö¿¡ ´ëÇØ ÀڽŸ¸ÀÇ ¼³Á¤°ú ¿¡·¯, ·Î±× µð·ºÅ丮¸¦ °®°Ô µÈ´Ù. °¢°¢ÀÇ ¼­¹ö´Â ¶ÇÇÑ ÀڽŸ¸ÀÇ Listen°ú VirtualHost µð·ºÅ丮¸¦ °¡Áö°í ÀÖ¾î¾ß ÇÑ´Ù. httpd.init ÆÄÀÏ¿¡¼­µµ ¿©·¯°³ÀÇ ¼­¹ö¸¦ ¼³Á¤ÇØ ÁÖ¾î¾ß ÇÑ´Ù´Â »ç½ÇÀ» ÀØÁö ¸»¶ó.

8.4 ÇϳªÀÇ IP¿¡¼­ ¼­¹ö °øÀ¯

IP Àý¾àÇϱâ

HTTP(HyperText Transfer Protocol) ¹öÀü 1.1¿¡´Â ¼­¹öÀÇ À̸§À» Ŭ¶óÀ̾ðÆ®¿¡ ¾Ë¸®´Â ±â´ÉÀÌ Ãß°¡µÇ¾ú´Ù. ÀÌ°ÍÀº Ŭ¶óÀ̾ðÆ®°¡ ¼­¹ö¸¦ ãÀ» ¶§ IP ¾îµå·¹½º·Î ºÎÅÍ Ã£À» ÇÊ¿ä°¡ ¾ø´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù. µû¶ó¼­ µÎ°³ÀÇ °¡»ó ¼­¹ö°¡ °°Àº IP ¾îµå·¹½º¸¦ °¡Áö°í ¼­·Î ´Ù¸¥ À¥ »çÀÌÆ®·Î ²Ù¹Ð ¼ö ÀÖ´Ù. ¾ÆÆÄÄ¡ ¼³Á¤Àº À§¿Í ¶È°°Àºµ¥, ´ÜÁö ¼­·Î ´Ù¸¥ ListenÀ» Áö½ÃÇÒ ÇÊ¿ä°¡ ¾ø´Ù´Â Á¡¸¸ ´Ù¸£´Ù. (µÎ°³ÀÇ µµ¸ÞÀÎÀÌ °°Àº IP¸¦ ¾²±â ¶§¹®¿¡ Listen ¿ª½Ã °°°Ô µÈ´Ù.)

°áÁ¡

¿ÀÁ÷ ¹®Á¦°¡ µÇ´Â Á¡Àº virtuald°¡ µµ¸ÞÀÎÀ» ±¸ºÐÇϱâ À§Çؼ­ IP ¾îµå·¹½º¸¦ »ç¿ëÇÑ´Ù´Â Á¡ÀÌ´Ù. Áö±Ý ÇöÀçÀÇ virtuald ÇüÅ·δ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇÑ ½ºÇ® µð·ºÅ丮¸¦ chroot·Î ´Ù¸£°Ô ¼³Á¤ÇÒ ¼ö ¾ø´Ù. µû¶ó¼­, ¸ÞÀÏÀº ÇϳªÀÇ IP¿¡ ´ëÇؼ­¸¸ ¹ÝÀÀÇÒ ¼ö Àֱ⠶§¹®¿¡ °¢°¢ÀÇ µµ¸ÞÀο¡ ´ëÇؼ­ µ¶ÀÚÀûÀÎ ½ºÇ® µð·ºÅ丮¸¦ °®´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù. IP¸¦ °øÀ¯ÇÏ´Â ¸ðµç À¥ Ŭ¶óÀ̾ðÆ®´Â IPÀÇ ½ºÇ® µð·ºÅ丮 ¿ª½Ã °øÀ¯ÇØ¾ß ÇÑ´Ù. ¶Ç ÀÌ°ÍÀº »ç¿ëÀÚÀ̸§À» º¹»çÇؼ­ »ç¿ëÇÏ´Â °Í¿¡ ´ëÇÑ ¹®Á¦¸¦ ¾ð±ÞÇÏ°Ô ÇÏÁö¸¸, ÀÌÁ¤µµ´Â IP¸¦ °øÀ¯ÇÔ¿¡ À־ ÇÊ¿äÇÑ ´ë°¡ÀÏ °ÍÀÌ´Ù.

8.5 ´õ ¸¹Àº Á¤º¸

ÀÌ ÇÏ¿ìÅõ´Â ´ÜÁö ¾î¶»°Ô °¡»ó ½Ã½ºÅÛÀ» ¾ÆÆÄÄ¡ À¥ ¼­¹ö¿¡¼­ Á¦°øÇÒ ¼ö ÀÖ´ÂÁö¸¸À» º¸¿©ÁÖ°í ÀÖ´Ù. ´ëºÎºÐÀÇ À¥ ¼­¹öµéÀº ºñ½ÁÇÑ ÀÎÅÍÆäÀ̽º¸¦ °®´Â´Ù. °¡»ó À¥ È£½ºÆÿ¡ ´ëÇØ ´õ ¸¹Àº ³»¿ëÀ» ¾Ë°í½Í´Ù¸é WWW HOWTO, ¸¦ Âü°íÇϰųª, ¾ÆÆÄÄ¡¿¡ ´ëÇÑ ¹®¼­µé ( Apache »çÀÌÆ®¿¡¼­ ±¸ÇÒ ¼ö ÀÖ´Ù) ȤÀº ApacheWeek¸¦ ã¾Æº¸¶ó.


´ÙÀ½ ÀÌÀü Â÷·Ê