Web Servers

Apache 2.4.63 리눅스 설치 방법 | 소스 컴파일부터 기동까지 완벽 가이드

midworker 2025. 4. 27. 15:26
반응형

리눅스 환경에서 Apache 2.4.63을 소스 컴파일로 설치하는 방법을 안내합니다. 필수 OS 패키지 설치, 소스 다운로드 및 컴파일, 아파치 기동/정지 스크립트 작성과 PATH 등록까지 전체 절차를 실무 기준으로 정리했습니다.

Apache 2.4.63 리눅스 설치 방법 | 소스 컴파일부터 기동까지 완벽 가이드

Apache HTTP Server 2.4.63, 리눅스 서버에 설치하고 운영하는 완벽 가이드
Apache HTTP Server 2.4.63, 리눅스 서버에 설치하고 운영하는 완벽 가이드


Apache 설치 테스트 환경

설치 OS : Rocky Linux release 8.10 (Green Obsidian)
설치 Apache : Apache HTTP Server 2.4.63


OS 패키지 설치

sudo yum install -y gcc gcc-c++ make pcre pcre-devel expat-devel openssl-devel wget

설치 파일 준비

# 아파치 다운로드
wget https://downloads.apache.org/httpd/httpd-2.4.63.tar.gz

# 압축 해제
tar -xzvf httpd-2.4.63.tar.gz

# 경로 이동
cd httpd-2.4.63/srclib

# apr, apr-util 다운로드
wget https://archive.apache.org/dist/apr/apr-1.7.3.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.6.3.tar.gz

# apr 압축 해제 및 폴더명 변경
tar zxvf apr-1.7.3.tar.gz
mv apr-1.7.3 apr

# apr-util 압축 해제 및 폴더명 변경
tar zxvf apr-util-1.6.3.tar.gz
mv apr-util-1.6.3 apr-util

Apache 컴파일 설치

# 경로 이동
cd ..

# configure 실행
./configure \
--prefix=/usr/local/apache2.4 \
--enable-so \
--enable-ssl \
--enable-rewrite \
--enable-proxy \
--enable-proxy-http \
--enable-deflate \
--enable-headers \
--enable-expires \
--enable-status \
--enable-socache-shmcb \
--enable-mpms-shared=all \
--enable-mods-shared=all \
--with-mpm=event

# make 병렬 빌드
make -j$(nproc)

# 설치
make install

Apache 기동/정지 스크립트 생성

# 아파치 기동 스크립트 작성
cd /usr/local/apache2.4
vi apache_start.sh

# 파일 내용
#!/bin/bash
/usr/local/apache2.4/bin/apachectl start
:wq

# 아파치 정지 스크립트 작성
vi apache_stop.sh

# 파일 내용
#!/bin/bash
/usr/local/apache2.4/bin/apachectl stop
:wq

# 실행 권한 부여
chmod +x apache_start.sh apache_stop.sh

# PATH 등록
vi ~/.bash_profile

# 파일 내용
export PATH=$PATH:/usr/local/apache2.4

# 변경 사항 적용
source ~/.bash_profile

Apache 기동과 확인

# 어디서든 기동
apache_start.sh

# 기동 확인 - 프로세스 확인
ps -ef | grep httpd

# 기동 확인 - 포트 확인
netstat -na | grep LISTEN | grep "80 "

# 기동 확인 - 로그 확인
cd /usr/local/apache2.4/logs
vi error_log
# 로그 예시
AH00094: Command line: '/usr/local/apache2.4/bin/httpd'

Apache 정지와 확인

# 어디서든 정지
apache_stop.sh

# 정지 확인 - 프로세스 확인
ps -ef | grep httpd

# 정지 확인 - 포트 확인
netstat -na | grep LISTEN | grep "80 "

# 정지 확인 - 로그 확인
cd /usr/local/apache2.4/logs
vi error_log
# 로그 예시
AH00491: caught SIGTERM, shutting down

궁금한 점이나 잘 되지 않는 부분이 있다면 댓글로 남겨주세요.

반응형