본문 바로가기

Linux Server

[CentOS 7.8] Linux 아파치(Apache) 웹 구성 및 컴파일

테스트 환경

네이버 클라우드 플랫폼(NCP) 일반 리눅스 서버 (CentOS 7.8)

 

1.아파치설치

# yum install java-1.8*

# wget https://downloads.apache.org/httpd/httpd-2.4.51.tar.gz

# wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz

# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz

# tar -zxvf httpd-2.4.51.tar.gz tar -xvzf apr-1.6.5.tar.gz tar -xvzf apr-util-1.6.1.tar.gz

# mv apr-1.6.5 httpd-2.4.51/srclib/apr mv apr-util-1.6.1 httpd-2.4.51/srclib/apr-util mkdir /apache

# yum install expat-devel

 

2.아파치 컴파일

# ./httpd-2.4.51/configure --prefix=/apache/httpd-2.4.51 --with-included-apr --enable-so --enable-ssl=shared --with-ssl=/usr/local/ssl --enable-rewrite --with-included-apr-util --with-included-pcre

# make

# make install

 

3.아파치 서비스 등록

# vi /usr/lib/systemd/system/httpd.service

아래 내용 작성 후 저장

 

httpd.service 내용.txt
0.00MB

 

# vi /apache/httpd-2.4.51/conf/httpd.conf

내용중 user, group 에 daemon이라고 되어있는부분 nobody로 수정

 

4.아파치 시작,확인,종료

# systemctl daemon-reload

# systemctl start httpd

# systemctl status httpd

 

# systemctl stop httpd

 

# vi /apache/httpd-2.4.51/conf/httpd.conf (아래처럼 내용에서 DocumentRoot & Directory 변경)

DocumentRoot "/var/www/html" <Directory "/var/www/html">

 

# vi /var/www/html/index.html (생성후 편집)

<h1> web01 server running </h1>

 

# systemctl enable httpd;systemctl start httpd

(웹페이지 확인 or curl -s http://localhost)