본문으로 바로가기

[CentOS] Apache(아파치) 구조

category 리눅스/CentOS 2013. 7. 9. 01:39

yum으로 Apache 패키지 설치시 관련 파일들 위치를 알아봅니다.

파일 위치와 기능

기본 설정파일 위치 : /etc/httpd/conf/httpd.conf

그 밖의 추가 애플리케이션 설정 위치 : /etc/httpd/conf.d/ (php.conf, phpmyadmin.conf, ssl.conf 등이 위치하게 된다)

로그 파일 위치 : /etc/httpd/logs -> /var/log/httpd 링크되어 있다.

모듈 위치(64비트) : /etc/httpd/modules -> /usr/lib64/httpd/modules 링크되어 있다.

프로세스의 PID 저장위치 : /etc/httpd/run -> /var/run/httpd 링크되어 있다.

기본 홈페이지 위치 : /var/www/html

CGI 파일들이 실행될 위치 : /var/www/cgi-bin

에러코드별 에러파일 위치 : /var/www/error

이미지아이콘 파일들 위치 : /var/www/icons

ls -la /etc/httpd

  합계 16
  drwxr-xr-x   4 root root 4096 2013-07-08 20:30 .
  drwxr-xr-x. 64 root root 4096 2013-07-08 15:39 ..
  drwxr-xr-x   2 root root 4096 2013-07-08 23:44 conf
  drwxr-xr-x   2 root root 4096 2013-07-08 22:56 conf.d
  lrwxrwxrwx   1 root root   19 2013-07-03 23:59 logs -> ../../var/log/httpd
  lrwxrwxrwx   1 root root   29 2013-07-03 23:59 modules -> ../../usr/lib64/httpd/modules
  lrwxrwxrwx   1 root root   19 2013-07-03 23:59 run -> ../../var/run/httpd
ls -la /var/www

  합계 24
  drwxr-xr-x   6 root root 4096 2013-07-03 23:59 .
  drwxr-xr-x. 18 root root 4096 2013-07-03 23:59 ..
  drwxr-xr-x   2 root root 4096 2013-05-14 07:12 cgi-bin
  drwxr-xr-x   3 root root 4096 2013-07-03 23:59 error
  drwxr-xr-x   2 root root 4096 2013-07-05 01:24 html
  drwxr-xr-x   3 root root 4096 2013-07-04 00:42 icons

프로세스

Apache의 프로세스들은 root 소유의 부모 프로세스 하나와 그 이하의 자식 프로세스로 구성된다. 즉, PID가 2090인 프로세스에 의해 모든 Apache 자식 프로세스들을 fork 시켜서 생성한 것이며 초기에는 8개만 생성하였지만 상황에 따라서 Apache 자식 프로세스들을 더 생성하기도 하고 줄이기도 한다. 이 역할을 하는 것이 2090 PID를 가진 프로세스의 역할이다.

ps -ef | grep httpd

  root      2090     1  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2092  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2093  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2094  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2095  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2096  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2097  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2098  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  nobody    2099  2090  0 08:03 ?        00:00:00 /usr/sbin/httpd
  root      2106  1544  0 08:04 pts/0    00:00:00 grep httpd

명령어

yum을 이용한 패키지설치를 하였다면 Apache와 관련된 명령어들이 /usr/sbin에 자동으로 설치된다. /usr/sbin은 PATH설정이 되어 있는 곳이다.

rpm -ql httpd | grep /usr/sbin

  /usr/sbin/apachectl
  /usr/sbin/htcacheclean
  /usr/sbin/httpd
  /usr/sbin/httpd.event
  /usr/sbin/httpd.worker
  /usr/sbin/httxt2dbm
  /usr/sbin/rotatelogs
  /usr/sbin/suexec

현재 상태 확인

service httpd status

  httpd (pid  2090)를 실행하고 있습니다..

설정파일 검사

httpd -t

  Syntax OK

모듈 적재 방식

DSO(Dynamic Shared Object)방식으로 모듈이 컴파일 되었는가 확인. mod_so.c 가 등록되어 잇다면 DSO방식으로 설치된 것이다.

httpd -l 

  Compiled in modules:
    core.c
    prefork.c
    http_core.c
    mod_so.c

컴파일 환경

prefork 방식에 64bit APR util 버전등을 알수 있다.

httpd -V

  Server version: Apache/2.2.15 (Unix)
  Server built:   May 13 2013 22:11:16
  Server's Module Magic Number: 20051115:25
  Server loaded:  APR 1.3.9, APR-Util 1.3.9
  Compiled using: APR 1.3.9, APR-Util 1.3.9
  Architecture:   64-bit
  Server MPM:     Prefork

    threaded:     no

      forked:     yes (variable process count)

  Server compiled with....
   -D APACHE_MPM_DIR="server/mpm/prefork"
   -D APR_HAS_SENDFILE
   -D APR_HAS_MMAP
   -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
   -D APR_USE_SYSVSEM_SERIALIZE
   -D APR_USE_PTHREAD_SERIALIZE
   -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
   -D APR_HAS_OTHER_CHILD
   -D AP_HAVE_RELIABLE_PIPED_LOGS
   -D DYNAMIC_MODULE_LIMIT=128
   -D HTTPD_ROOT="/etc/httpd"
   -D SUEXEC_BIN="/usr/sbin/suexec"
   -D DEFAULT_PIDLOG="run/httpd.pid"
   -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
   -D DEFAULT_LOCKFILE="logs/accept.lock"
   -D DEFAULT_ERRORLOG="logs/error_log"
   -D AP_TYPES_CONFIG_FILE="conf/mime.types"
   -D SERVER_CONFIG_FILE="conf/httpd.conf"


'리눅스 > CentOS' 카테고리의 다른 글

[CentOS] Apache(아파치) 설정파일 분석 - httpd.conf  (10) 2013.07.18
[CentOS] Apache(아파치) 모듈  (1) 2013.07.09
[CentOS] PHP - APC 설정  (0) 2013.07.05
[CentOS] Anacron  (0) 2013.07.05
[CentOS] 방화벽 설정 - iptables  (65) 2013.07.01