본문 바로가기

리눅스

Apache HTTP Server 2.2.12 설치

728x90
반응형

Apache HTTP Server 2.2.12 설치

Apache HTTP Server 2.2.12를 소스 코드로 컴파일하여 /usr/local/apache2 경로에 설치하는 방법입니다.

1. Apache 계정 생성

useradd -c "Apache" -u 48 -s /sbin/nologin -m -d /home/www apache
id apache
uid=48(apache) gid=48(apache) groups=48(apache)

2. Apache 설치

Apache 소스 코드 압축 해제

  • Apache HTTP Server 2.2.12 소스 파일을 준비한 후 압축을 해제합니다.
tar -xzf httpd-2.2.12.tar.gz
cd httpd-2.2.12

 Configure

./configure \
  --prefix=/usr/local/apache2 \
  --enable-so \
  --enable-shared=max \
  --enable-rewrite \
  --enable-ssl \
  --enable-proxy
  • 주요 옵션
    • --prefix=/usr/local/apache2 Apache 설치 경로 지정
    • --enable-so DSO(Dynamic Shared Object) 모듈 지원
    • --enable-shared=max 가능한 모듈을 DSO 방식으로 빌드
    • --enable-rewrite mod_rewrite 활성화
    • --enable-ssl SSL/TLS 지원을 위한 mod_ssl 활성화
    • --enable-proxy Proxy 기능 활성화

Apache 컴파일

  • make를 실행하여 소스 코드를 컴파일합니다.
make -j$(nproc)

Apache 설치

  • 설치를 진행합니다.
make install

주요 디렉터리

/usr/local/apache2/ 
├── bin/ # Apache 실행 파일 및 관리 명령 
├── conf/ # Apache 설정 파일 
├── htdocs/ # 기본 웹 문서 경로 
├── logs/ # 로그 파일 
└── modules/ # Apache 모듈

Apache 설정 확인

/usr/local/apache2/bin/apachectl configtest

Apache 실행

/usr/local/apache2/bin/apachectl start
728x90

3. Apache 서비스 등록

SysV init 및 chkconfig를 사용하는 레거시 CentOS/RHEL 환경에서는 Apache를 시스템 서비스로 등록할 수 있습니다.

 

Apache에서 제공하는 apachectl을 init 스크립트 경로로 복사합니다.

cp -p /usr/local/apache2/bin/apachectl /etc/init.d/httpd

init 스크립트에 chkconfig 정보를 추가합니다.

vim /etc/init.d/httpd
# chkconfig: 2345 80 30
# description: HTTPD

chkconfig 등록

  • Apache 서비스를 chkconfig에 등록합니다.
chkconfig --add httpd

런레벨 3, 4, 5에서 자동으로 시작하도록 설정합니다.

chkconfig --level 345 httpd on

등록 상태 확인

chkconfig --list | grep httpd
httpd    0:off  1:off  2:off  3:on  4:on  5:on  6:off

4. Apache 서비스 확인

서비스 명령을 통해 Apache를 관리할 수 있습니다.

$ service httpd start
$ service httpd status
$ service httpd restart
$ service httpd stop

또는 apachectl을 직접 사용할 수도 있습니다.

$ /usr/local/apache2/bin/apachectl start 
$ /usr/local/apache2/bin/apachectl stop 
$ /usr/local/apache2/bin/apachectl restart

5. Apache 프로세스와 포트 확인

Apache가 정상적으로 HTTP 포트를 Listen하고 있는지 확인합니다.

 

Apache 프로세스 확인

ps -ef | grep [h]ttpd

Apache 포트 확인

netstat -lntp | grep httpd
ss -lntp | grep httpd

웹 브라우저 또는 curl을 이용하여 HTTP 응답 확인

curl -I http://127.0.0.1/
HTTP/1.1 200 OK

 

Apache HTTP Server 2.2.12를 소스 코드로 컴파일하고 SysV init 및 chkconfig를 이용하여 시스템 서비스로 등록하는 과정을 마무리합니다.

 

728x90
반응형