728x90
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf
더보기
# # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information. # In particular, see # <URL:http://httpd.apache.org/docs/2.4/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. # # 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 'log/access_log' # with ServerRoot set to '/www' will be interpreted by the # server as '/www/log/access_log', where as '/log/access_log' will be # interpreted as '/log/access_log'. # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # Do not add a slash at the end of the directory path. If you point # ServerRoot at a non-local disk, be sure to specify a local disk on the # Mutex directive, if file-based mutexes are used. If you wish to share the # same ServerRoot for multiple httpd daemons, you will need to change at # least PidFile. # ServerRoot "/etc/httpd" # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of 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. # #Listen 12.34.56.78:80 Listen 80 # # Dynamic Shared Object (DSO) Support # # 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 # Include conf.modules.d/*.conf # # 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. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # User apache Group apache # 'Main' server configuration # # The directives in this section set up the values used by the 'main' # server, which responds to any requests that aren't handled by a # <VirtualHost> definition. These values also provide defaults for # any <VirtualHost> containers you may define later in the file. # # All of these directives may appear inside <VirtualHost> containers, # in which case these default settings will be overridden for the # virtual host being defined. # # # ServerAdmin: Your address, where problems with the server should be # e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@your-domain.com # ServerAdmin root@localhost # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 # # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> AllowOverride none Require all denied </Directory> # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # 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 "/var/www/html" # # Relax access to content within /var/www. # <Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory> # Further relax access to the default document root: <Directory "/var/www/html"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Require all granted </Directory> # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html </IfModule> # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ".ht*"> Require all denied </Files> # # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a <VirtualHost> # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a <VirtualHost> # container, that host's errors will be logged there and not here. # ErrorLog "logs/error_log" # # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel warn <IfModule log_config_module> # # The following directives define some format nicknames for use with # a CustomLog directive (see below). # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> # # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a <VirtualHost> # container, they will be logged here. Contrariwise, if you *do* # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # #CustomLog "logs/access_log" common # # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> # # Redirect: Allows you to tell clients about documents that used to # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: # Redirect permanent /foo http://www.example.com/bar # # Alias: Maps web paths into filesystem paths and is used to # access content that does not live under the DocumentRoot. # Example: # Alias /webpath /full/filesystem/path # # If you include a trailing / on /webpath then the server will # require it to be present in the URL. You will also likely # need to provide a <Directory> section to allow access to # the filesystem path. # # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> # # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> # # TypesConfig points to the file containing the list of mappings from # filename extension to MIME-type. # TypesConfig /etc/mime.types # # AddType allows you to add to or override the MIME configuration # file specified in TypesConfig for specific file types. # #AddType application/x-gzip .tgz # # AddEncoding allows you to have certain browsers uncompress # information on the fly. Note: Not all browsers support this. # #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz # # If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: # AddType application/x-compress .Z AddType application/x-gzip .gz .tgz # # AddHandler allows you to map certain file extensions to "handlers": # actions unrelated to filetype. These can be either built into the server # or added with the Action directive (see below) # # To use CGI scripts outside of ScriptAliased directories: # (You will also need to add "ExecCGI" to the "Options" directive.) # #AddHandler cgi-script .cgi # For type maps (negotiated resources): #AddHandler type-map var # # Filters allow you to process content before it is sent to the client. # # To parse .shtml files for server-side includes (SSI): # (You will also need to add "Includes" to the "Options" directive.) # AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> # # Specify a default charset for all content served; this enables # interpretation of all content as UTF-8 by default. To use the # default browser choice (ISO-8859-1), or to allow the META tags # in HTML content to override this choice, comment out this # directive: # AddDefaultCharset UTF-8 <IfModule mime_magic_module> # # The mod_mime_magic module allows the server to use various hints from the # contents of the file itself to determine its type. The MIMEMagicFile # directive tells the module where the hint definitions are located. # MIMEMagicFile conf/magic </IfModule> # # Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://www.example.com/subscription_info.html # # # EnableMMAP and EnableSendfile: On systems that support it, # memory-mapping or the sendfile syscall may be used to deliver # files. This usually improves server performance, but must # be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise # broken on your system. # Defaults if commented: EnableMMAP On, EnableSendfile Off # #EnableMMAP off EnableSendfile on # Supplemental configuration # # Load config files in the "/etc/httpd/conf.d" directory, if any. IncludeOptional conf.d/*.conf
분석
httpd.conf 주요 항목
- 아파치 웹 서버의 기본적인 설정을 담당하는 파일
- 소스로 설치했을 경우에 /usr/local/apache/conf 디렉터리 안에 위치한다.
항목 1
ServerRoot "/usr/local/apache
- 웹 서버가 설치된 디렉터리를 나타냄.
항목 2
Listen 80
- 아파치 웹 서버의 포트를 설정함.
- 아파치 1.3 버전의 Port 지시자를 대체하여 Listen을 사용함.
항목 3
LoadModule authn_file_module modules/mod_authn_file.so ... LoadMoudle php5_module modules/libphp5.so
- DSO(Dynamic Shared Object)로 사용되는 모듈을 나타냄.
항목 4
User daemon Group daemon
- 실행되는 httpd 데몬의 사용자 및 그룹 권한을 나타냄.
항목 5
ServerAdmin starrykss@starrykss.org
- 서버에 문제가 발생했을 경우 보낼 관리자의 이메일 주소를 적음.
항목 6
ServerName www.starrykss.org:80
- 서버의 도메인 이름을 적음.
- 만약 도메인이 없을 경우 IP 주소를 적음.
- 실제 이름이 아닌 가상의 이름도 가능함.
- 2.0 버전부터는 도메인명 뒤에 포트 번호를 명시하도록 하고 있음.
- 처음 설치 시에는 주석(#)처리가 되어 있으니 제거해야 웹 데몬을 시작할 때 경고 메시지를 없앨 수 있음.
항목 7
DocumentRoot "/usr/local/apache/htdocs"
- 웹 문서가 위치하는 디렉터리를 나타냄.
항목 8
<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory>
- 전체 디렉터리에 대한 기본 옵션이나 권한을 나타냄.
항목 9
<Directory /usr/local/apache/htdocs> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
- <Directory /> ~ </Directory>
- 특정 디렉터리를 제어할 때 사용하는 지시자
- 각 디렉터리에 대한 권한 등 여러 설정을 할 수 있음.
- 사용되는 설정 항목
- Options
- 다음의 사용 여부 결정
- CGI
- SSI(Server Side Includes)
- 디렉터리의 심볼릭 링크
- 항목
- NONE : 어떤 옵션도 이용할 수 없으므로 모든 접근 거부
- ALL : MultiViews 옵션을 제외한 모든 옵션 부여 (기본값)
- Includes : 서버측의 추가적인 정보 제공 (SSI: Server Side Includes)
- Indexes : URL 이 지정된 디렉터리에 index.html과 같은 지정된 파일이 없을 경우, 해당 디렉터리의 파일 목록을 보여주는 옵션
- FollowSymLinks : 디렉터리 내에서 심볼릭 링크의 사용을 허가
- ExecCGI : CGI 스크립트를 실행할 수 있도록 허가
- IncludesNOEXEC : SSI 는 허용하지만, #exec 명령과 CGI 스크립트 #include는 불허
- MultiViews
- All 옵션이 설정되었을 때만 지정된 목록이 multiviews를 허용하는 것으로 유사한 파일 이름을 찾아주는 기능 수행
- 예) index라고만 입력해도 index.*를 찾아서 보여줌.
- 다음의 사용 여부 결정
- AllowOverride
- 사용자 인증에 관련된 요소
- 웹 클라이언트가 특정 디렉터리에 접근할 때 해당 디렉터리에 있는 유저 인증 파일인 .htaccess 파일을 읽게됨.
- 여기서 None 을 설정하면 아파치 서버는 이 파일을 무시하게 됨.
- 항목
- NONE
- AllowOverride를 사용 하지 않음.
- 즉, 유저 인증 파일을 사용하지 않음.
- 아파치 서버는 이 파일을 무시하게 됨.
- ALL : httpd.conf 파일의 AccessFileName 지시자로 설정한 파일을 사용하고, 관련 지시자를 사용할 수 있음.
- AuthConfig
- AccessFileName 지시자에 명시한 파일에 대해서 사용자 인증 지시자 사용을 허락
- 다음을 사용할 수 있음.
- AuthDBMGroupFile
- AuthDBMUserFile
- AuthGroupFile
- AuthName
- AuthType
- AuthUserFile
- require
- FileInfo
- AccessFileName 지시자로 설정한 파일에 대해서 문서 유형을 제어하는 지시자 사용을 허락
- 다음을 사용할 수 있음.
- AddEncoding
- AddLanguage
- AddType
- DefaultType
- ErrorDocument
- LanguagePriority
- Indexes
- AccessFileName 지시자로 설정한 파일에 대해서 디렉터리 Indexing 을 제어하는 지시자 사용을 허락
- 다음을 사용할 수 있음.
- AddDescription
- AddIcon
- AddIconByEncoding
- AddIconByType
- DefaultIcon
- DirectoryIndex
- FancyIndexing
- HeaderName
- IndexIgnore
- IndexOptions
- ReadmeName
- Limit
- AccessFileName 지시자로 설정한 파일에 대해서 호스트 접근을 제어하는 지시자 사용을 허락
- 다음을 사용할 수 있음.
- Allow
- Deny
- order
- Options
- AccessFileName 지시자에 명시한 파일에 대해서 Options 그리고 XBitHack 등과 같은 지시자 사용을 허락
- 다음을 사용할 수 있음.
- Options
- XBitHack
- NONE
- Order
- 해당 디렉터리에 접근하는 호스트 인증을 담당함.
- 해당 디렉터리에 대해 IP 주소 및 도메인에 대한 필터링 순서를 설정함.
- Allow : 호스트 접근 허락
- Deny : 호스트 접근 거부
- Allow from all : 모든 호스트로부터의 접근 허락
- Deny from all : 모든 호스트로부터의 요청 거부
- 예
Order deny,allow Deny from all Allow from 호스트명 - Require
- 접근 권한을 거부하거나 허가할 때 사용
- Options
항목 10
<IfModule dir_module> DirectoryIndex index.html </IfModule>
- 디렉터리 인덱스 파일(처음 열리는 파일)로 사용할 파일 이름을 적음.
- 기본 index.html에 필요에 따라 index.htm, index.php, index.php7 등을 추가하도록 함.
항목 11
<Files ".ht*"> Require all denied </Files>
- .ht로 시작하는 파일에 대한 접근을 거부하는 설정
- 아파치 사용자 인증 파일인 .htaccess에 대한 권한 설정
항목 12
ErrorLog logs/error_log
- 웹 서버에 에러가 발생했을 경우, 에러에 관한 기록 파일을 설정함.
- <VirtualHost> 지시자에서 ErrorLog 설정을 하지 않았다면, 여기에서 언급한 설정을 따름.
- 로그 파일의 경우는 계속해서 사용량이 증가하므로 수시로 용량을 줄여야 함.
항목 13
LogLevel warn
- 로그 메시지의 크기를 제어하는 부분
- 옵션 : debug, info, notice, warn, error, crit, alert, emerg 등
항목 14
<IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "logs/access_log" common #CustomLog /usr/local/apache/logs/access_log combined </IfModule>
- 로그 관련 형식 및 관련 파일에 대한 설정을 하는 곳
- LogFormat
- 로그의 형식을 지정하는 부분
- 사용 지시자
- %h : 호스트명
- %l : 리모트 로그 이름
- %u : 사용자 인증에 사용된 유저명
- %t : 시간
- %r : 요청한 내용의 첫 번째 줄
- %s : 서버 상태
- $b : 전송량(헤더 포함) - 바이트수
- %{헤더} : 요구된 헤더 내용
- &U : 요구한 URL
- CustomLog : 웹 서버에 접근한 정보를 기록해주는 access_log 파일의 위치를 설정하는 부분
- access, agent, referer 정보를 하나의 파일에 모두 저장하기를 원한다면 combined 옵션을 이용함.
항목 15
<IfModule alias_module> ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" </IfModule>
- Alias 와 같은 기능을 하는 지시자
- CGI 스크립트 파일이 있는 경로를 지정함.
항목 16
DefaultType text/plain
- 파일 확장자를 정의해 두는 것
- MIME 타입을 알 수 없는 문서에 대하여 사용할 기본 MIME 타입을 설정함.
- 기본값 : text/plain
- Mime Type 을 결정하지 못할 때는 기본 텍스트 문서로 결정
- 주로 서버에 문서 파일이 많을 경우에 사용함.
- 웹 브라우저 상에서 실행 프로그램이나 이미지 등 바이너리인 경우에 웹 브라우저가 바이너리라고 해석하려면 application/octet-stream과 같은 형식을 적어줘야 함.
- 웹 브라우저가 실행 파일 등을 텍스트 문서로 착각하고 브라우저상에 표시하지 않게 하기 위함.
항목 17
<IfModule mine_module> TypesConfig conf/mime.types #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz #AddHandler cgi-script .cgi #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml </IfModule>
- TypesConfig
- mime.types 파일 또는 이에 해당하는 파일을 찾을 위치를 결정함.
- MIME
- Multipurpose Internet Mail Extension 의 약자
- 클라이언트 브라우저에게 어떠한 유형의 자료를 전송할 것인지를 조절해주는 기능
- AddEncoding
- 일부 브라우저에서 전송을 받으면서 정보를 압축 해제할 수 있도록 허용할 때 사용하는 것
- 모든 브라우저에서 이 기능을 지원하지는 않음.
- AddType
- 추가로 지원될 파일을 적는 부분
- PHP 를 사용할 경우에는 이 영역에 다음의 두 줄을 추가해주면 mime.types의 수정 없이 mime을 설정 가능하게 해줌.
AddType application/x-httpd-php .php .htm .html .inc .php4 .php5 AddType application/x-httpd-php-source .phps - AddHandler
- 특정 파일 확장자나 처리기에 연결하거나 특정 파일 타입에 특정 동작 연결을 설정하는 부분
- 어떤 파일 확장자를 파일 종류와 무관하게 작동할 수 있게 Handler에 결합되도록 설정해주는 것
- .shtml 관련 두 줄
- SSI 문서로 인식할 파일 확장자를 지정하는 부분
- SSI 코드를 사용하는 문서의 확장자를 .shtml로 지정함.
항목 18
#MIMEMagicFile /conf/magic
- mod_mime_magic 모듈을 사용할 경우, 해당 파일의 내용으로 파일 타입 힌트를 얻는 역할을 함.
- MIMEMagicFile
- 암시를 정의하는 모듈이 어디에 위치하고 위치를 알려주는 것
- 이것을 사용하기 위해서는 해당 모듈을 탑재해야 함.
항목 19
# Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://www.example.com/subscription_info.html
- 에러 페이지에 대한 요청을 처리하는 부분
- 존재하지 않는 페이지에 대해 요청받을 경우
- 해당 디렉터리의 퍼미션이 없는 경우
- 보통 에러 페이지에 대한 처리는 3가지가 있음.
- 간단히 텍스트 메시지 출력
- 내부 URL 로 전환
- 외부 URL 로 전환
항목 20
#Include conf/extra/httpd-mpm.conf
- MPM(Multi Processing Modules) 관련 설정이 필요한 경우
- 이 줄의 주석(#)을 제거
- httpd-mpm.conf에서 설정하면 됨.
항목 21
#Include conf/extra/httpd-multilang-errordoc.conf
- 에러 문서 처리에 대한 설정이 필요한 경우
- 이 줄의 주석(#)을 제거
- httpd-multilang-errordoc.conf에서 설정하면 됨.
항목 22
#Include conf/extra/httpd-autoindex.conf
- 디렉터리 목록 표시와 관련하여 설정할 경우
- 이 줄의 주석(#)을 제거
- httpd-autoindex.conf에서 설정하면 됨.
항목 23
#Include conf/extra/httpd-languages.conf
- 문서의 언어 표시와 관련하여 설정할 경우
- 이 줄의 주석(#)을 제거
- httpd-languages.conf에서 설정하면 됨.
항목 24
#Include conf/extra/httpd-userdir.conf
- 사용자의 홈 디렉터리를 사용할 경우
- 이 줄의 주석(#)을 제거
- httpd-userdir.conf에서 설정하면 됨.
항목 25
#Include conf/extra/httpd-info.conf
- 웹 브라우저를 이용하여 웹 서버의 상태 정보를 파악하고자 할 경우
- 이 줄의 주석(#)을 제거
- httpd-info.conf에서 설정하면 됨.
항목 26
#Include conf/extra/httpd-vhosts.conf
- 버추얼 호스트를 사용하는 경우
- 이 줄의 주석(#)을 제거
- httpd-vhosts.conf에서 설정하면 됨.
항목 27
#Include conf/extra/httpd-manual.conf
- 서버 상에서 아파치 메뉴얼을 사용할 경우
- 이 줄의 주석(#)을 제거
- httpd-manual.conf에서 설정하면 됨.
항목 28
#Include conf/extra/httpd-dav.conf
- WebDAV 관련하여 설정이 필요한 경우
- 이 줄의 주석(#)을 제거
- httpd-dav.conf에서 설정하면 됨.
항목 29
#Include conf/extra/httpd-default.conf
- Timeout 등 웹 서버 운영과 관련된 다양한 기본 설정이 필요한 경우
- 이 줄의 주석(#)을 제거
- httpd-default.conf에서 설정하면 됨.
항목 30
<IfModule proxy_html_module> Include conf/extra/proxy-html.conf </Ifmodule>
- HTML 4 및 XHTML 1 을 해석과 관련된 mod_proxy_html을 설정할 때 사용함.
항목 31
<IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule>
- SSL 모듈 관련 설정
728x90
'System Software > Linux' 카테고리의 다른 글
[리눅스] NFS(Network File System) (0) | 2022.03.18 |
---|---|
[리눅스] NTP(Network Time Protocol) (0) | 2022.03.18 |
[리눅스] KVM(Kernel-based Virtual Machine) (0) | 2022.03.18 |
[리눅스] vsftpd (0) | 2022.03.17 |
[리눅스] /etc/fstab (0) | 2022.03.17 |
[리눅스 명령어] iptables / iptables-save / iptables-restore (0) | 2022.03.16 |
[리눅스 명령어] ntpq / ntpdate (0) | 2022.03.16 |
[리눅스 명령어] named-checkconf / named-checkzone (0) | 2022.03.16 |