Apache2 Configuration

Apache2 기본 설정 (Basic Configuration of Apache2)

Apache2의 기본 디렉토리 구조 이해 (Understanding the Basic Directory Structure of Apache2)

Apache2는 다양한 설정 파일과 디렉토리를 사용하여 웹 서버를 관리합니다. 주요 디렉토리와 그 역할을 이해하는 것이 중요합니다.

주요 디렉토리 (Key Directories)
  • conf: Apache 설정 파일들이 위치한 디렉토리입니다. 주요 설정 파일인 httpd.conf가 이곳에 있습니다.
  • htdocs: 웹 서버의 기본 문서 루트 디렉토리입니다. 웹 페이지 파일(html, css, js 등)이 여기에 위치합니다.
  • logs: Apache의 로그 파일들이 저장되는 디렉토리입니다. 접근 로그(access.log)와 오류 로그(error.log) 파일이 포함되어 있습니다.
  • modules: Apache 모듈 파일들이 위치한 디렉토리입니다. 모듈을 추가하거나 제거할 수 있습니다.

주요 설정 파일 (Key Configuration Files)

httpd.conf 파일의 구성 (Structure of httpd.conf File)

httpd.conf는 Apache의 주요 설정 파일로, 서버의 동작을 제어하는 다양한 디렉티브(directive)가 포함되어 있습니다. 이 파일은 텍스트 파일로 구성되어 있으며, 주석은 # 기호로 시작합니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 주석은 #으로 시작합니다.
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin you@example.com
ServerName www.example.com:80
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
# 주석은 #으로 시작합니다. ServerRoot "/etc/httpd" Listen 80 Include conf.modules.d/*.conf User apache Group apache ServerAdmin you@example.com ServerName www.example.com:80 DocumentRoot "/var/www/html" <Directory "/var/www"> AllowOverride None Require all granted </Directory>
# 주석은 #으로 시작합니다.
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin you@example.com
ServerName www.example.com:80
DocumentRoot "/var/www/html"
<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>
설정 파일의 주요 디렉티브 (Key Directives in Configuration File)
  • Listen: Apache가 요청을 수신할 포트를 지정합니다. 기본값은 80(HTTP)입니다.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Listen 80
Listen 80
  Listen 80
  • ServerName: 서버의 도메인 이름과 포트를 지정합니다. 도메인 기반 가상 호스트 설정에 사용됩니다.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ServerName www.example.com:80
ServerName www.example.com:80
  ServerName www.example.com:80
  • DocumentRoot: 웹 서버의 기본 문서 루트를 지정합니다. 웹 페이지 파일들이 위치하는 디렉토리입니다.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
DocumentRoot "/var/www/html"
DocumentRoot "/var/www/html"
  DocumentRoot "/var/www/html"
  • Directory: 특정 디렉토리에 대한 설정을 정의합니다. 주로 접근 제어와 관련된 설정을 포함합니다.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
  <Directory "/var/www/html">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
  </Directory>
  • Options: 디렉토리 내에서 허용할 옵션을 지정합니다. 예를 들어, Indexes는 디렉토리 목록을 표시하고, FollowSymLinks는 심볼릭 링크를 허용합니다.
  • AllowOverride: .htaccess 파일에서 특정 지시어를 재정의할 수 있도록 허용합니다.
  • Require: 접근 제어를 지정합니다. 예를 들어, Require all granted는 모든 사용자에게 접근을 허용합니다.
기본 설정 파일 구성 예제 (Example of Basic Configuration File)

다음은 간단한 httpd.conf 파일의 예제입니다.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# 서버의 루트 디렉토리를 지정합니다.
ServerRoot "/etc/httpd"
# 서버가 수신할 포트를 지정합니다.
Listen 80
# 서버 관리자 이메일을 설정합니다.
ServerAdmin admin@example.com
# 서버의 도메인 이름과 포트를 설정합니다.
ServerName www.example.com:80
# 웹 서버의 기본 문서 루트를 설정합니다.
DocumentRoot "/var/www/html"
# 웹 문서 루트 디렉토리에 대한 설정을 정의합니다.
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# 로그 파일 위치를 설정합니다.
ErrorLog "/var/log/httpd/error.log"
CustomLog "/var/log/httpd/access.log" common
# 서버의 루트 디렉토리를 지정합니다. ServerRoot "/etc/httpd" # 서버가 수신할 포트를 지정합니다. Listen 80 # 서버 관리자 이메일을 설정합니다. ServerAdmin admin@example.com # 서버의 도메인 이름과 포트를 설정합니다. ServerName www.example.com:80 # 웹 서버의 기본 문서 루트를 설정합니다. DocumentRoot "/var/www/html" # 웹 문서 루트 디렉토리에 대한 설정을 정의합니다. <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> # 로그 파일 위치를 설정합니다. ErrorLog "/var/log/httpd/error.log" CustomLog "/var/log/httpd/access.log" common
# 서버의 루트 디렉토리를 지정합니다.
ServerRoot "/etc/httpd"

# 서버가 수신할 포트를 지정합니다.
Listen 80

# 서버 관리자 이메일을 설정합니다.
ServerAdmin admin@example.com

# 서버의 도메인 이름과 포트를 설정합니다.
ServerName www.example.com:80

# 웹 서버의 기본 문서 루트를 설정합니다.
DocumentRoot "/var/www/html"

# 웹 문서 루트 디렉토리에 대한 설정을 정의합니다.
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

# 로그 파일 위치를 설정합니다.
ErrorLog "/var/log/httpd/error.log"
CustomLog "/var/log/httpd/access.log" common

이 설정 파일은 기본적인 Apache 서버를 구성하는데 필요한 핵심 요소들을 포함하고 있습니다. 이를 통해 서버의 기본 동작을 제어할 수 있으며, 필요에 따라 추가적인 모듈 및 설정을 추가하여 서버를 확장할 수 있습니다.

Leave a Reply

Your email address will not be published. Required fields are marked *