본문 바로가기

Linux Server 구축/1-2. Web Server

Apache WebServer - httpd.conf - Section 1: Global Environment


Apache HTTP Server Version 2.2에 대한 자세한 정보  :
http://httpd.apache.org/docs/2.2/

-----------------------------------------------------------------------------------------------------

httpd.conf 파일은 크게 세부분으로 나누어져 있다.

    Section 1: Global Environment  - 아파치 전체적인 영향이 미치는 설정
    Section 2: 'Main' server configuration - 주 서버에 대한 설정
    Section 3: Virtual Hosts - 가상 호스트에 대한 설정

자, 그럼 이제부터 이 아파치웹서버의 모든 환경을 설정하는 아파치 환경설정 파일 httpd.conf파일의 설정방법에 대해서 상세히 알아보도록 하자.

-----------------------------------------------------------------------------------------------------

Section 1: Global Environment

전제환경설정 파트로 Section 1에서 설정하는 것들은 아파치 웹서버에 전반적인 영향을 미친다.

-----------------------------------------------------------------------------------------------------

#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/etc/httpd" will be interpreted by the
# server as "/etc/httpd/logs/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# Don't give away too much information about all the subcomponents
# we are running.  Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS - 해당 서버의 웹서버 정보를 보여준다.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/httpd" - 아파치 웹서버의 설정파일이 위치하는 디렉토리를 나타낸다.

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
PidFile run/httpd.pid - 웹서버 구동시 PID 값을 기록하는 파일을 나타낸다.

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 120 - 서버와 클라이언트 연결시 아무런 메시지가 없을 때 오류로 처리되는 시간으로 단위는 초이다.

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive Off - 지속적인 접속의 허용여부를 설정한다.
off로 설정시 : 클라이언트의 요청이 없으면 접속을 끊음
on으로 설정시 : 클라이언트의 요청이 없어도 계속 접속을 유지함

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
- KeepAlive가 설정(on) 되었을 경우 지속적인 접속 기간동안 처리 할수 있는 요청개수를 의미한다.
값이 0 일 경우 무한대이다.

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15 - KeepAlive 가 설정(on)되었을 경우 클라이언트의 요청이 타임아웃되는 시간을 초 단위로 나타낸다.

##
## Server-Pool Size Regulation (MPM specific)
##

MPM
- MPM(Multi-Processing Modules)의 약자로 아파치 서버 2.x 버전이 소개되면서 기존 1.3 버전이 안고 있는 확정성 부분과
하나의 프로세스가 제공해 주지 못했던 신뢰성을 기존의 프로세스 방식과 스레드를 혼용한 방식으로 해결하도록 하였는데
이것이 바로 MPM방식이다.

MPM의 종류
- prefork MPM
- worker MPM
- perchild MPM ---> Apache를 소스로 설치한 경우에만 나타난다.

# prefork MPM
- 아파치 1.3 버전에서 사용되는 방식으로 클라이언트의 요청에 의해 각각의 프로세스가 생성이 되며
프로세스를 제어하는 부모 프로세스는 클라이언트 요청이 들어올 경우 대기하고 있다가 자식 프로세스의 생성여부 등을 관리한다.
즉, 프로세스 <----> 클라이언트 방식이다.

- 아파치 2.x 버전에서 특별히 지정하지 않으면 prefork 모듈을 사용한다.

# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8 - 서버 시작시 자식 프로세스 개수 지정
MinSpareServers    5  - 최소로 유지해야 할 여분의 자식 프로세스의 수
MaxSpareServers   20 - 최대로 제한되어야 할 여분의 자식 프로세스의 수
ServerLimit      256 - 자식 프로세스의 최대 개수 지정
MaxClients       256 - 클라이언트들이 동시 접속할 수 있는 최대 개수 지정
MaxRequestsPerChild  4000 - 자식프로세스가 죽기 전에 처리할 수 있는 요청 개수
</IfModule>

# worker MPM
- prefork MPM 방식에 기반을 두고 모듈로 지정된 만큼의 스레드에 얼마나 많은 자식 프로세스를 생성할 것인지를 지정한다.
즉, 프로세스 ---- 스레드 <----> 클라이언트 방식이다.

# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers         2 - 서버 시작시 자식 프로세스 개수 지정
MaxClients         150 - 클라이언트들이 동시 접속할 수 있는 최대수 지정
MinSpareThreads     25 - 최소로 유지해야 할 여분의 스레드 수
MaxSpareThreads     75 - 최대로 제한되어야 할 여분의 스레드 수
ThreadsPerChild     25 - 자식 프로세스당 생성하는 스레드 값
MaxRequestsPerChild  0 - 값이 0 이면 자식 프로세스는 죽지 않고 계속 처리한다.
</IfModule>

#perchild MPM
- 서버 시작시에 고정적인 프로세스 개수를 정의 하며, 각 프로세스는 특정 스레드 개수로 동작한다.
즉, 프로세스 ---- 스레드 ---- perchild <----> 클라이언트 방식이다.

<IfModule worker.c>
NumServers         5 - 서버 시작시 프로세스의 개수 지정
StartThreads       5 - 자식 프로세스에 의해 실해오디는 스레드의 수
MinSpareThreads     5 - 최소 여분의 스레드 수
MaxSpareThreads     10 - 최대여분의 스레드 수
MaxThreadsPerChild     20 - 자식 프로세스가 생성할 수 있는 최대 스레드의 수
MaxRequestsPerChild  0 - 값이 0 이면 자식 프로세스는 죽지 않고 계속 처리한다.
</IfModule>

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80 - 아파치 웹서버의 포트를 설정한다.

#
# Dynamic Shared Object (DSO) Support
- 동적 객제지원(Dynamic Shared Object) 방식으로 모듈을 적재한다.
즉, 1.3 버전처럼 원하는 모듈 추가시 모듈 전체를 컴파일 하는 것이 아닌 원하는 모듈만 추가/제거 할 수 있는 방식이다.
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule version_module modules/mod_version.so

#
# The following modules are not loaded by default:
#
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule asis_module modules/mod_asis.so

#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf - 웹서버와 연동하는 프로그램과 환경설정파일을 불러온다.

#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On

#
# 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".
#  . On HPUX you may not be able to use shared memory as nobody, and the
#    suggested workaround is to create a user www and use that user.
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
#  when the value of (unsigned)Group is above 60000;
#  don't use Group #-1 on these systems!
#
User apache
Group apache
- 아파치라는 사용자와 그룹을 가진 사용자에 의해 웹서버를 실행한다.



httpd.conf 한글 번역 파일