nugawiki

./categories/server

Apache httpd.conf 지시자

업데이트 2026-07-21 조회수

CentOS 6.4 / Apache 2.2.15 yum 기준. 경로: /etc/httpd/conf/httpd.conf

핵심 지시자

지시자설명
ServerTokens Prod응답 헤더 최소화 (Server: Apache)
ServerRoot "/etc/httpd"Apache 홈, 이후 상대경로 기준
PidFile run/httpd.pidPID 파일
Timeout 300무응답 시 연결 종료(초)
KeepAlive On지속 연결
MaxKeepAliveRequests 100연결당 최대 요청 (0=무제한)
KeepAliveTimeout 2다음 요청 대기(초)
Listen 80리슨 포트
User/Group nobody자식 프로세스 소유자
ServerNameCanonical 호스트명
UseCanonicalName Off클라이언트가 보낸 Host 사용
DocumentRoot "/var/www/html"문서 루트 (/ 끝 X)
DirectoryIndex기본 문서 목록
AccessFileName .htaccess디렉터리별 접근 제어 파일
HostnameLookups Off로그에 IP만 (DNS 질의 부하 방지)
ErrorLog / LogLevel warn에러 로그
CustomLog ... combined액세스 로그
ServerSignature On|Off|EMail에러 페이지 서명

MPM (prefork / worker)

<IfModule prefork.c>
    StartServers       8
    MinSpareServers    5
    MaxSpareServers   20
    ServerLimit      256
    MaxClients       256
    MaxRequestsPerChild 4000
</IfModule>

<IfModule worker.c>
    StartServers         4
    MaxClients         300
    MinSpareThreads     25
    MaxSpareThreads     75
    ThreadsPerChild     25
    MaxRequestsPerChild  0
</IfModule>

Directory / Options / AllowOverride

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/var/www/html">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
  • Options: None, Indexes, Includes, FollowSymLinks, ExecCGI, MultiViews
  • AllowOverride: None, All, AuthConfig, FileInfo, Indexes, Options, Limit
  • Order: allow,deny / deny,allow

.ht* 차단 / Alias

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

Alias /icons/ "/var/www/icons/"
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

server-status (로컬망만)

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 192.168.0.0/24
</Location>

ExtendedStatus On 권장. 점검: httpd -S

가상호스트

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /www/docs/example.com
    ServerName example.com
    ErrorLog logs/example.com-error_log
    CustomLog logs/example.com-access_log common
</VirtualHost>

php.conf (/etc/httpd/conf.d/php.conf)

AddHandler php5-script .php
AddType text/html .php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

./comments