다음 이전 차례

8. 아파치(Apache) HTTP 서버 설치와 운영

단순한 클라이언트로의 전락! 인터네트 사용인구가 늘어나긴 해도 그리고 네트워크 속도가 빨라지기는 했지만 개인 사용자들은 여전히 진정한(?) 사용자 수준에 머물고 있다. 하지만 PC 한 대와 리눅스 그리고 적당한 속도의 네트워크만 있다면 이제 여러분의 리눅스 머신은 더 이상 클라이언트 머신이 아니다. 웹서비스를 상용으로 할 것이 아니라면 네트워크 속도는 모뎀속도 정도만 돼도 상관없지 않을까? SLIP이나 PPP로 동적 IP를 할당받아 가끔 운영해보는 개인 서버도 재미있을 것이다. 잠시 서버로 작동하는 여러분의 리눅스 머신으로 친구들을 초대해보는 것도 좋다. 현재 조사된 바에 의하면 전세계적으로 가장 많이 사용되는 웹 서버는 단연 아파치 서버이며 우리나라에서는 NCSA서버를 가장 많이 사용한다고 한다. 몇 가지 문서를 찾아보면 우리나라에서 NCSA서버가 가장 많이 사용되는 이유로 한글화된 문서가 있다는 사실을 들고 있다. NCSA 서버의 버그를 수정하면서 (아파치 서버의 이름은 NCSA 1.3에 대한 A PAtCHy 버전이라는 말로부터 유래된 것이라 한다), 가장 빠른 서버로 인정되고 있으며 전세계적으로 가장 많이 사용되는 아파치 서버에 대한 한글 문서가 나온다면 좋은 성능의 아파치 서버가 국내에서도 많이 사용되리라 믿으며 이 글을 적는다. 필자가 접할 수 있고 마음대로 사용할 수 있는 유일한 시스템은 리눅스이기 때문에 리눅스에서의 아파치 서버 설치/운영 방법과 사용자 확인(User Authentification)에 대해 간단히 기술한다. 아파치 서버 대부분의 기능은 NCSA 서버로부터 물려받은 것이기 때문에 NCSA 서버 문서만으로도 충분하지만 아파치 서버 특유의 기능 또는 확장된 개념들이 존재하므로 NCSA에서 찾아 불 수 없는 부분을 주목하고 싶다. 다른 운영체계에서 설치, 운영하는 법이나 더 많은 정보를 원한다면 이 글 마지막에 있는 여러 참고자료들을 직접 찾아보기 바란다.

8.1 준비사항

8.2 설치

1) 아파치 서버 소스 풀기 먼저 아파치 소스를 /usr/local/etc에 복사하고 압축을 푼다.

/usr/local/etc# tar xvzf apache_1.1.1.tar.gz

apache_1.1.1이라는 디렉토리가 생기며 아파치 서버와 관련된 모든 파일이 풀려 나온다. 일반적으로 아파치 서버 배포본은 httpd라는 디렉토리 아래에 설치되므로 링크를 만들어주거나 httpd 라는 이름을 바꾸도록 하자.

/usr/local/etc# mv apache_1.1.1 httpd

또는

/usr/local/etc# ln -s apache_1.1.1 httpd

2) 디렉토리 설명 압축을 풀었다면 다음과 같은 내용을 볼 수 있다.

-rw-r--r--     1 129   kmem  3738 Mar 13  1996 CHANGES
-rw-r--r--     1 129   kmem   2604 Feb 22  1996 LICENSE
-rw-r--r--     1 129   kmem   3059 Jul  3 15:24 README
drwxr-xr-x     2 129  kmem   1024 Jul  9 04:04 cgi-bin/
drwxr-xr-x     2 129   kmem  1024 Jul  9 04:04 conf/
drwxr-xr-x     2 129   kmem  1024 Jul  9 04:04 htdocs/
drwxr-xr-x     2 129  kmem   2048 Jul  9 04:04 icons/
drwxr-xr-x     2 129  kmem   1024 Jul  9 04:04 logs/
drwxr-xr-x     2 129  kmem   2048 Jul 10 00:02 src/
drwxr-xr-x     2 129  kmem   1024 Jul  9 04:05 support/

디렉토리명   디렉토리 내용
cgi-bin      CGI 스크립트 모음
conf         아파치 실행할 때 환경 초기값 설정파일
htdocs       일반적인 서버 홈페이지 디렉토리
icons        아파치 서버 자체적으로 사용하는 아이콘
logs         여러 가지 사용 기록 저장 파일
src          아파치 소스
support      서버의 보안에 관련된 프로그램들이 들어있다.

8.3 컴파일 전 src/Configuration 파일 수정

먼저 Configuration.tmpl 파일을 Configuration으로 복사한다.

/usr/local/etc/httpd/src# cp Configuration.tmpl Configuration

에디터로 Configuration파일을 불러들여 수정을 시작해 보자.

Configuration 파일에 있는 모듈의 목록은 활성화되든 되지 않든 상관없이 모두 src 디렉토리에 소스로 포함되어 있다. 하지만 새로운 기능의 모듈들 예를 들어 포스트그래스95용 모듈인 mod_auth_pg95을 사용하기 위해서는 해당 소스를 src 디렉토리에 포함시키고 Configuration파일에도 포함시켜야 한다. 모듈은 파일의 이름을 보면 그 기능을 대강 알 수 있으며 더 자세히 알고자 한다면 http://www.apache.org/docs/modules.html에서 많은 정보를 얻을 수 있을 것이다. 기본적으로 제공되고 활성화된 모듈은 다음과 같다.

mime_module
access_module
auth_module
negotiation_module
includes_module
dir_module
cgi_module
userdir_module
alias_module
env_module
common_log_module

기본적으로 제공되나 사용자가 명시적으로 활성화시켜야 하는 것들은 다음과 같다.

asis_module
imap_module
action_module
agent_log_module
referer_log_module
config_log_module
cern_meta_module
status_module
info_module
anon_auth_module
db_auth_module
dbm_auth_module
msql_auth_module
digest_module
dld_module
cookies_module
proxy_module

8.4 컴파일

모듈설정까지 마쳤으면 이제 저장을 하고, ./Configure를 실행시킨 뒤 컴파일을 한다.

/usr/local/etc/httpd/src# ./Configure
Using 'Configuration' as config file
/usr/local/etc/httpd/src# make

8.5 서버 환경 설정

컴파일이 성공적으로 완료되었으면 src 디렉토리에 httpd가 생성되었을 것이다. 이제는 서버의 환경을 설정해 주자. conf 디렉토리에는 4개의 환경 설정파일이 있다. 그 중 *.conf-dist 파일을 *.conf로 복사하고 그 복사본을 가지고 서버의 환경설정을 해주자.

/usr/local/etc/httpd/conf# cp access.conf-dist access.conf
/usr/local/etc/httpd/conf# cp httpd.conf-dist httpd.conf
/usr/local/etc/httpd/conf# cp srm.conf-dist srm.conf

access.conf파일 수정

Directory에 지정된 디렉토리를 서버의 홈디렉토리로 지정한다.

<Directory /usr/local/etc/httpd/htdocs>
Options Indexes FollowSymLinks

가능한 옵션은 다음과 같다.

None : 어떤 옵션도 이용할 수 없다.
All : MultiViews 옵션을 이용할 수 있다.
Indexes : URL에 지정된 디렉토리에 (index.html 같은)지정된 파일이 없을
          경우 디렉토리의 파일 목록을 보여주는 옵션.
Includes : 서버측의 추가적인 정보를 제공할 수 있게 한다.
FollowSymLinks : 디렉토리의 심볼릭 링크를 사용 가능하게 한다.
ExecCGI : CGI 스크립트를 실행할 수 있게 한다.
MultiViews : All 옵션이 설정되었을 때만 지정된 목록의 multiviews를 허용한다.

# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
AllowOverride None
.htaccess파일은 서버의 각 디렉토리에 대한 접근을 제어하기 위한 것으로 디렉토리에 .htaccess파일이 있으면 서버 전체에 작용하는 access.conf보다 우선권을 가진다. 다음은 .htaccess파일에 대한 Override에 대한 옵션이다.

None : .htaccess파일을 읽을 수 없게 한다.
All : 모든 지정에 대해 가능하게 한다.
Options : 규정된 디렉토리 형식을 컨트롤하는 지정의 사용을 허락한다.
FileInfo : 문서형식을 컨트롤하는 지정의 사용을 허용한다.
AuthConfig : 사용자 인증 지정의 사용을 허용한다. 사용자 인증 변수를 사용한다.
Limit : 호스트 접근을 컨트롤하는 지정을 허용한다.

# Controls who can get stuff from this server.
order allow,deny
allow from all

</Directory>

order : 서버가 액세스 컨트롤을 수행하는 순서를 나타낸다. allow기능을 먼저
        수행하고, deny기능을 수행하라는 것이다.
allow from : 나열되는 주소들에 대한 액세스 컨트롤을 가능하게 한다. 사용
             가능한 주소는 도메인 네임, 호스트 이름 주소, 호스트 ip 주소,
             ip주소의 앞부분 3바이트, 모든 주소에 해당하는 all이 있다.
deny from : allow from과 반대되는 개념이며 사용 가능한 주소는 allow from
            과 같다.
require : 사용자, 그룹에 대한 접근을 통제할 수 있다.
 사용방법 : require entity en1 en2 ... enn
            entity에 들어갈 수 있는 것은 user, group, valid-user의 세 가지이다.
user : 지정된 사용자들에게만 접근을 허용하는 것으로 지정된 사용자에 대한
       정보는 AuthUserFile에서 지정한 파일에 있다.
group : 지정된 그룹에게만 접근을 허용하는 것으로 지정된 그룹에 대한 정보는
        AuthGroupFile에서 지정한 파일에 있다.
valid-user : AuthUserFile에 있는 모든 사용자에 대해 접근을 허용한다.

# /usr/local/etc/httpd/cgi-bin should be changed to whatever your
# ScriptAliased CGI directory exists, if you have that configured.
cgi-bin디렉토리에 대한 Options를 지정한다. 옵션은 htdocs 설정의 옵션과 같다.

<Directory /usr/local/etc/httpd/cgi-bin>
AllowOverride None
Options None
</Directory>

서버의 상태결과를 http://servename/status의 URL에 접근하면 볼 수 있게 해주는 옵션이다. 'allow from 서버 도메인 네임' 의 형식으로 접근이 가능하다.

#</Location /status>
#SetHandler server-status
#order deny,allow
#deny from all
#allow from .nowhere.com
#</Location>

그 외 접근 제어에 대한 관련 사항을 추가로 작성할 수 있다.

httpd.conf

# ServerType is either inetd, or standalone.
ServerType standalone
서버의 타입을 지정하는 것으로 standalone은 httpd 데몬 프로세스가 사용자의
요청을 처리하는 것이고 inetd는 inetd 데몬 프로세스가 처리하게 하는 것이다.
standalone이 더 효율적인 방법이다.

Port 80
시스템에 의해 미리 httpd를 위해 예약된 포트 번호는 80번이다. 0에서 1023
까지의 포트번호는 시스템에 의해 미리 예약되어 있다. 그 이상의 포트번호를
지정하여 일반사용자도 httpd을 설치, 운영 가능하다. http://aaa.bbb.ccc:8080/
등으로 사용할 수 있다.

HostnameLookups on
웹서버에 대한 접근을 도메인 네임이나 ip주소 (on) 또는 ip주소만으로(off)
접근하게 할 것인지를 결정하는 것이다.

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch. 
# User/Group: The name (or #number) of the user/group to run httpd as.
#  On SCO (ODT 3) use User nouser and Group nogroup User nobody
Group #-1
ServerType이 standalone일 때만 적용되는 것으로 서버가 사용자의 요청에 대해서
생성하는 child httpd 프로세스에 대한 user id, group id 이다. 일반적으로
시스템에서 사용하지 않는 것들로 지정하는 것이 바람직하다. 슬랙 3.1기반
배포본에는 /etc/group에 nogroup -2가 지정되어 있다.

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.
ServerAdmin you@your.address
서버 관리자의 e-mail 주소를 지정한다.

# ServerRoot: The directory the server's config, error, and log files
# are kept in
ServerRoot /usr/local/etc/httpd
서버의 Root 디렉토리를 지정한다.

# ErrorLog: The location of the error log file. If this does not start
# with /, ServerRoot is prepended to it.
ErrorLog logs/error_log
서버에서 발생하는 에러를 기록하는 로그 파일을 지정한다.

# TransferLog: The location of the transfer log file. If this does not
# start with /, ServerRoot is prepended to it.
TransferLog logs/access_log
서버에 대한 사용자들의 엑세스 정보를 기록하는 로그파일을 지정한다.

# PidFile: The file the server should log its pid to
PidFile logs/httpd.pid
httpd 데몬 프로세스의 프로세스 id를 기록하고 있는 파일을 지정한다.

# ScoreBoardFile: File used to store internal server process information
ScoreBoardFile logs/apache_status
서버 프로세스의 정보를 담고 있는 파일을 지정한다.

# ServerName allows you to set a host name which is sent back to clients
# for your server if it's different than the one the program would get (i.e.
# use "www" instead of the host's real name).
#
# Note: You cannot just invent host names and hope they work. The
# name you define here must be a valid DNS name for your host. If you
# don't understand this, ask your network administrator.
#ServerName new.host.name
서버의 도메인 네임을 지정한다. 자신의 서버가 도메인 네임을 가지지 않았다면
놔둔다. 가졌다면 활성화 시켜주고 도메인 네임을 기입한다.

# Timeout: The number of seconds before receives and sends time out
#  n.b. the compiled default is 1200 (20 minutes !)
Timeout 400
클라이언트가 정보를 받을 때까지 소요되는 대기시간의 최대 값을 지정한다.
네트워크가 응답이 늦을 수록 수치를 늘리는 것이 좋다.

# KeepAlive: The number of Keep-Alive persistent requests to accept
# per connection. Set to 0 to deactivate Keep-Alive support
KeepAlive 5
접속된 채로 특별한 요청이 없음에도 계속 연결을 유지시킬 수치를 지정한다.

# KeepAliveTimeout: Number of seconds to wait for the next request
KeepAliveTimeout 15
KeepAlive가 지정되었을 때 다음 요청을 기다리는 수치를 초 단위로 지정한다.

# Server-pool size regulation. Rather than making you guess how many
# server processes you need, 아파치 dynamically adapts to the load it
# sees --- that is, it tries to maintain enough server processes to
# handle the current load, plus a few spare servers to handle transient
# load spikes (e.g., multiple simultaneous requests from a single
# Netscape browser).
# It does this by periodically checking how many servers are waiting
# for a request. If there are fewer than MinSpareServers, it creates
# a new spare. If there are more than MaxSpareServers, some of the
# spares die off. These values are probably OK for most sites ---
MinSpareServers 5
MaxSpareServers 10
httpd 데몬프로세스의 child 프로세스에 대해 MinSpare Servers보다 작으면 새
로운 프로세스를 생성하고 MaxSpare Servers보다 많으면 여분의 프로세스를
죽이는(kill) 것을 지정한다.

# Number of servers to start --- should be a reasonable ballpark figure.
StartServers 5
httpd 서버를 처음 실행시킬 때 여분의 프로세스를 생성시킬 수치를 지정한다.

# Limit on total number of servers running, i.e., limit on the number
# of clients who can simultaneously connect --- if this limit is ever
# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO
LOW.
# It is intended mainly as a brake to keep a runaway server from taking
# Unix with it as it spirals down...
MaxClients 150
한번에 접근 가능한 클라이언트의 수치를 지정한다.

# MaxRequestsPerChild: the number of requests each child process is
# allowed to process before the child dies.
# The child will exit so as to avoid problems after prolonged use when
# 아파치 (and maybe the libraries it uses) leak. On most systems, this
# isn't really needed, but a few (such as Solaris) do have notable leaks
# in the libraries.
MaxRequestsPerChild 30
child 프로세스가 응답할 수치를 지정한다. 아마 리눅스에서는 상관 없는 듯하다.

# Proxy Server directives. Uncomment the following line to
# enable the proxy server:
#ProxyRequests On
아파치 서버는 프락시 서버의 기능도 하는데 on으로 활성화 시켜주면 된다.

# To enable the cache as well, edit and uncomment the following lines:
#CacheRoot /usr/local/etc/httpd/proxy
#CacheSize 5
#CacheGcInterval 4
#CacheMaxExpire 24
#CacheLastModifiedFactor 0.1
#CacheDefaultExpire 1
#NoCache adomain.com anotherdomain.edu joes.garage.com
프락시 서버를 지정했을 때 필요한 설정들이다.
Virtual 호스트 관련된 부분은 mini FAQ의 Virtual-Web문서를 읽어보기 바란다.

srm.conf

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /usr/local/etc/httpd/htdocs
'access.conf'의 DocumentRoot 지정부분과 동일하다.
# UserDir: The name of the directory which is appended onto a user's
# home directory if a ~user request is recieved.
UserDir public_html
시스템을 사용하는 일반 사용자들의 개인 웹 홈 디렉토리를 지정한다.
$HOME/public_html 디렉토리를 만들어서 홈페이지를 등록할 수 있다.
디렉토리명은 서버 관리자가 변경할 수 있다.

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
DirectoryIndex index.html
특정 파일을 지정하지 않고 디렉토리만 지정했을 때 불러들일 문서를 지정한다.

# FancyIndexing is whether you want fancy directory indexing or
# standard
FancyIndexing on
디렉토리의 내용을 보여줄 때 지정된 아이콘으로 보여줄 것인지 지정한다.

# AddIcon tells the server which icon to show for different files or
# filename extensions
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
....(중략)
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
지정된 아이콘 목록이다.

# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
DefaultIcon /icons/unknown.gif
아이콘 목록에 없는 파일을 보여줄 때 사용될 아이콘을 지정한다.

# AddDescription allows you to place a short description after a file in
# server-generated indexes.
# Format: AddDescription "description" filename
# ReadmeName is the name of the README file the server will look for
# by default. Format: ReadmeName name
#
# The server will first look for name.html, include it if found, and it will
# then look for name and include it as plaintext if found.
#
# HeaderName is the name of a file which should be prepended to
# directory indexes.
ReadmeName README
HeaderName HEADER
디렉토리 목록을 보여줄 때 목록의 마지막 부분 뒤와 목록의 시작 전에 보여줄
내용을 담고 있는 파일을 지정한다. 여기서는 목록의 뒤에 README, 목록의
처음에 HEADER를 보여주게 지정되어 있다.

# IndexIgnore is a set of filenames which directory indexing should ignore
# Format: IndexIgnore name1 name2...
IndexIgnore */.??* *~ *# */HEADER* */README* */RCS
디렉토리를 출력할 때 무시할 파일들을 지정한다.

# AccessFileName: The name of the file to look for in each directory
# for access control information.
AccessFileName .htaccess
서버가 디렉토리를 출력할 때 참고할 파일을 지정한다.

# DefaultType is the default MIME type for documents which the server
# cannot find the type of from filename extensions.
DefaultType text/plain
사용자의 요청으로 각 파일에 대한 행동을 취할 때 서버가 알지 못하는 형식의
파일일 경우 표시 형식을 지정한다.

# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+)
# uncompress information on the fly. Note: Not all browsers support this.
AddEncoding x-compress Z
AddEncoding x-gzip gz
압축 코드에 대한 인코딩정보를 지정한다.

# Redirect allows you to tell clients about documents which used to exist
# in your server's namespace, but do not anymore. This allows you to tell
# theclients where to look for the relocated document.
# Format: Redirect fakename url
가상 자료파일을 url에 지정된 문서로 Redirect 한다.

# Aliases: Add here as many aliases as you need (with no limit). The for
# mat is Alias fakename realname
#Alias /icons/ /usr/local/etc/httpd/icons/
파일명이나 디렉토리명을 alias 할 수 있다. 활성화 시켜준다.

# ScriptAlias: This controls which directories contain server scripts.
# Format: ScriptAlias fakename realname
#ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/
서버에서 사용하는 cgi를 담은 디렉토리를 지정한다. 이 디렉토리의 파일들은
서버에 의해 cgi스크립트로 인식된다. 활성화 시켜준다.
AddType은 ext에 해당하는 확장자를 가진 파일을 mime.types에 기술된 mime
type형태로 정의 하는 것이다.
형식 : AddType type/subtype ext1
AddHandler역시 ext에 해당하는 확장자에 대한 행동 양식을 정의하는 것이지
만, 일반적인 확장자를 가진 파일들에 대한 정의를 한다.
형식 : AddHandler action-name ext1

# To use CGI scripts:
#AddHandler cgi-script .cgi
서버의 어떤 위치에 있던지 .cgi 확장자를 가진 파일은 cgi-script로 인식하게
한다.
.pl, .sh 등의 다른 확장자도 추가할 수 있다.

# To use server-parsed HTML files
#AddType text/html .shtml
#AddHandler server-parsed .shtml
Server Side Includes (SSI)를 사용할 때 필요하다. SSI는 HTML파일 속에 어
떤 실행 프로그램의 결과나 특정 파일을 포함할 수 있게 한다.

# Uncomment the following line to enable 아파치's send-asis HTTP file
# feature
#AddHandler send-as-is asis
mime type sttpd/send-as-is에 대한 설정이다.

# If you wish to use server-parsed imagemap files, use
#AddHandler imap-file map
mime type application/x-httpd-imap에 대한 설정이다.

지정된 media type에 대해 해당 스크립트를 실행 가능하게 할 수 있다.
형식 : Action media/type /cgi-script/location
형식 : Action handler-name /cgi-script/location
예) Action text/html /cgi-bin/footer
CERN HTTP 서버의 meta information을 emulate해 준다. 자세한 내용은
CERN HTTP 서버문서를 읽어보길 바란다.

# MetaDir: specifies the name of the directory in which 아파치 can find
# meta information files. These files contain additional HTTP headers
# to include when sending the document

#MetaDir .web

# MetaSuffix: specifies the file name suffix for the file containing the
# meta information.

#MetaSuffix .meta


# Customizable error response (아파치 style)
# these come in three flavors
# 서버 에러에 대한 응답을 지정해 줄 수 있습니다.
# 각 에러 코드에 대한 응답을 cgi나 일반 텍스트로 만들어서 사용자에게
보여줄 수 있다. 어떤 서버에 접속하면 해당 URL이 없다는 등의 한글메시지가
가능한 것도 이것을 이용하는 것이다.
#    1) plain text
#ErrorDocument 500 "The server made a boo boo.
#  n.b.  the (") marks it as text, it does not get output
#
#    2) local redirects
#ErrorDocument 404 /missing.html
#  to redirect to local url /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#  n.b. can redirect to a script or a document using server-side-includes.
#
#    3) external redirects
#ErrorDocument 402 http://other.server.com/subscription_info.html
#

mime.types

mime.types파일은 서버에 의해 리턴되는 파일의 파일명과 MIME형식을 기술하는
것에 대해 규정한다.
type/subtype ext1 ext2 ext3 ...으로 기술되며 ext1 등은 파일명이 해당 확장자를
가졌을 때 클라이언트에게 전달되는 확장자이다.
예) video/mpeg                      mpeg mpg mpe

8.6 서버의 실행

위에서와 같이 환경설정을 마쳤으면, 아파치 서버를 실행시켜보자. 루트 권한으로

/usr/local/etc/httpd/src/httpd -f /usr/local/etc/httpd/conf/httpd.conf
를 실행해도 되며 /etc/ rc.d/rc.local 등에 위의 내용을 삽입하면 부팅할 때 자동으로 아파치 서버가 작동한다.

사용 가능한 옵션은 다음과 같다.

-d serverroot 보통 httpd.conf에 지정된 ServerRoot 변수에 대한 지정을 할
              수 있게 한다. 디폴트는 /usr/local/etc/httpd 이다.

-f config     환경설정 파일을 지정해서 시작하게 한다. 지정된 config파일이
              / 로 시작하지  않으면 ServerRoot에 대한 상대패스로 인식한다.
              디폴트는 conf/httpd.conf 이다.

-X            내부적인 테스트를 위해 싱글 프로세스 모드로 실행시킨다.
              서버 데몬은 아들 프로세스를 fork하지 않는다.  웹서비스를 하려면
              이 모드를 사용하지 말라.

-v            httpd의 버전을 프린트하고 실행을 마친다.

-?            httpd의 옵션을 프린트하고 실행을 마친다.

8.7 사용자 인증(User Authentication)

사용자가 문서에 접근하려 할 때 사용자를 확인하는 것을 말한다. 이것은 사용자의 아이디와 패스워드를 확인함으로써 가능하다. 사용자 인증을 위해서는 다음 환경변수를 지정해 주어야 한다. conf/access.conf파일에 지정하면 서버의 모든 디렉토리를 대상으로 하고 각 디렉토리에 conf/srm.conf의 Access FileName변수에서 지정한 파일이름(보통 .htaccess)이 존재하면 그 파일을 참조한다. conf/access.conf 파일의 디렉토리 지정부분에 AllowOverride AuthConfig지정을 해주면 아래의 환경변수를 사용할 수 있다. access.conf파일의 설명을 참조하기 바란다.

AuthType Basic

사용하는 인증의 방식을 지정한다. 현재까지 Basic만 구현되어 있다.

AuthName somedomain

사용자 인증을 확인하는 확인처의 이름을 밝힌다. 여러 이름을 나열할 수 있다.

AuthUserFile /web/users

인증된 사용자의 데이터를 보관할 파일을 지정한다. support디렉토리에 보면 몇 가지 보안에 관련된 프로그램들이 소스 형태로 존재한다. 이것을 make명령을 주어 컴파일하고 나면 실행 가능한 파일들 중 htpasswd라는 명령이 생성되며 이 명령이 사용자를 등록시키는 일을 수행한다. /web/에 지정된 디렉토리에서 ../support/htpasswd -c users username 라고 해주면 사용자가 생성되며 새로운 사용자 등록은 -c 옵션을 빼고 명령을 주면 된다. 사용자 삭제는 해당 파일에서 사용자 데이터 부분을 삭제해주면 된다.

AuthGroupFile /web/groups

인증된 그룹의 데이터를 보관한다. 이 파일은 직접 만들어 주면 된다.

 예)  group1: user1 user2 user3
      group2: user2 user5 user6

다음은 /usr/local/etc/httpd/htdocs 디렉토리의 접근 제어를 AuthUserFile에 지정된 사용자에 대해서만 접근을 허용하도록 설정을 마친 access.conf의 내용이다.

<Directory /usr/local/etc/httpd/htdocs>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
order allow,deny
allow from all
AuthType Basic
AuthName liberty
AuthUserFile /usr/local/etc/httpd/conf/users
AuthGroupFile /usr/local/etc/httpd/conf/group
require valid-user
</Directory>

8.8 리눅스 파일 시스템 표준에 따르기

알짜웨어에 있는 아파치 1.0 을 설치하면 아파치 실행 파일을 제외하고는 cgi-bin, conf, htdocs, icons, logs 등의 디렉토리가 모두 /var/lib/httpd라는 디렉토리 아래 있음을 알 수 있다. 리눅스 파일 시스템 표준에서는 시스템 운영 도중에 갱신되는 자료들에 대해서는 /usr 파티션 아래 두는 것을 권장하지 않는다. 특히 htdocs, logs 등은 빈번하게 변화하는 디렉토리이므로 /var에 위치하고 있어야 한다. 이전 아파치 서버를 설치했다면 우선은 pkgtool을 가지고 삭제를 한다. 그리고 /usr/local/etc/httpd에 있는 것들을 모두 /var/lib/httpd로 옮긴 다음 /usr/local/etc/httpd는 단지 /var/lib/httpd에 대한 링크로 만들어두는 것이 좋다. 파일 시스템 표준에 대해서 잘 모르는 사람은 그냥 넘어가도 좋다.

8.9 마치며

가장 좋은 웹서버로 인정되는 아파치 서버가 단지 소개 글 하나 없다는 이유로 국내에서는 거의 쓰이지 않고 있다는 것에 안타까움을 느끼며 적은 지식이나마 아파치 서버를 운영해본 경험을 바탕으로 이 글을 썼다. 이후 SSL(Secure Socket Layer) 등의 아파치 서버의 많은 기능을 정리한 글을 작성할 예정이다.


다음 이전 차례