Apache 서버의 httpd.conf 주요 설정 항목은 무엇인가요?
💡 요약 정리
- Apache 서버의 httpd.conf는 웹 서버의 핵심 설정 파일입니다.
- 웹루트, 포트, 관리자 이메일, MIME 타입 등 다양한 서버 동작 요소를 제어합니다.
- 접근 제어(Directory, FilesMatch), 로그 설정, 모듈 로딩 등의 내용을 포함합니다.
- 설정을 변경한 후에는 반드시 아파치 서버를 재시작해야 반영됩니다.
Apache의 설정 파일인 httpd.conf는 서버의 루트 디렉토리, 서비스 포트, 관리자 메일 주소, 문서 루트 디렉토리, 모듈 로딩, 접근제어 등 다양한 요소들을 설정할 수 있는 구성 파일입니다.
아래는 주요 설정 항목에 대한 설명입니다.
1. 기본 설정
-
ServerRoot "/usr/local/apache"- 아파치 서버가 설치된 루트 디렉토리입니다.
-
Listen 80- 아파치가 사용할 기본 포트를 설정합니다.
-
LoadModule php5_module modules/libphp5.so- PHP 연동을 위한 모듈 로딩 설정입니다.
-
User daemon,Group daemon- 아파치가 실행될 때 사용할 OS 사용자 및 그룹입니다.
-
ServerAdmin you@example.com- 서버관리자의 이메일 주소입니다.
-
ServerName www.example.com- 웹 서버 이름을 정 의합니다.
-
DocumentRoot "/usr/local/apache/htdocs"- 웹 문서들이 위치한 루트 디렉토리입니다.
2. 디렉토리 접근제어
-
<Directory />- 시스템 루트(/) 디렉토리에 대한 접근제어 설정
Options FollowSymLinks AllowOverride None Order deny,allow Deny from all -
<Directory "/usr/local/apache/htdocs">- DocumentRoot 디렉토리에 대한 접근제어 설정
Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
3. Index 파일 설정
<IfModule dir_module>DirectoryIndex index.html index.htm index.php- 디폴트로 호출할 index 파일의 우선순위를 설정합니다.
</IfModule>
4. 숨겨진 파일 접근제어
<FilesMatch "^.ht">Order allow,deny Deny from all Satisfy All.ht로 시작하는 파일들에 대한 접근을 제한합니다.
</FilesMatch>
5. 로그 설정
-
ErrorLog "logs/error_log"- 에러 로그 파일 경로입니다.
-
LogLevel warn- 로그 레벨을 warn으로 설정합니다.
-
<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># 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> -
CustomLog "logs/access_log" common- 액세스 로그 파일의 경로 설정입니다.
-
</IfModule>
6. CGI Script 설정
-
<IfModule alias_module>ScriptAlias /cgi-bin/ "/svc/test/web/apache/cgi-bin/"- CGI 스크립트 경로의 alias 설정입니다.
-
</IfModule> -
<Directory "/svc/test/web/apache/cgi-bin">AllowOverride None Options None Order allow,deny Allow from all- cgi-bin 디렉토리 접근 제어 설정
-
</Directory>
7. MIME 타입 설정
-
DefaultType text/plain- 기본 MIME 타입을 text/plain으로 설정
-
<IfModule mime_module>TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php .php3 .ph .inc .html .htm .tpl AddType application/x-httpd-php-source .phps- 확장자별 MIME 타입 및 PHP 소스 확장자 리스트
-
</IfModule>
8. 추가 설정 파일 포함 (주석 처리 상태)
-
#Include conf/extra/httpd-mpm.conf- MPM 설정 (ex. MaxClients 등)
-
#Include conf/extra/httpd-multilang-errordoc.conf- 다국어 에러 메시지 설정
-
#Include conf/extra/httpd-autoindex.conf- Index 파일이 없을 경우 디렉토리 내 파일 리스트 출력 설정
-
#Include conf/extra/httpd-languages.conf- 기본 언어셋 외에 지원할 언어 설정
-
#Include conf/extra/httpd-userdir.conf- 일반 계정의 홈 디렉토리 설정
- 예:
http://도메인/~계정
-
#Include conf/extra/httpd-info.conf- 실시간 요청 및 설정 정보 출력
-
#Include conf/extra/httpd-vhosts.conf- 가상 호스트 설정
-
#Include conf/extra/httpd-manual.conf- Apache 매뉴얼 출력
-
#Include conf/extra/httpd-dav.conf- WebDAV 설정
-
#Include conf/extra/httpd-default.conf- Apache 기본 설정
-
#Include conf/extra/httpd-ssl.conf- SSL/TLS 보안 설정
9. SSL 모듈 설정
<IfModule ssl_module>SSLRandomSeed startup builtin SSLRandomSeed connect builtin</IfModule>