[RHCSA 준비] 아파치 서버 구성하기

blog post 

* 참고

- 아파치 서버 구성 자체가 rhcsa 시험 출제 항목은 아닙니다.

- 설정 과정에서 원활한 구성을 위해 잠시 SElinux를 꺼두지만, 실제로 구성하는 과정에서는 끄지 않는 것이 좋습니다.

 

주요 구성 파일 설명

/etc/httpd/conf/httpd.conf : 아파치 서버 메인 구성 파일

  • DocumentRoot: 실제 아파치 웹 서버가 있는 기본 위치
  • ServerRoot: 그 아파치 서버의 구성 파일이 있는 위치

 

/etc/httpd/conf/magic : 브라우저에 의해 사용되는 파일로, 웹서버의 콘텐츠를 해석하는 방법에 대해 명시되어 있다. 

/etc/httpd/conf.d/ : 아파치 구성파일에 포함된 파일들이 있다.

/etc/httpd/conf.modules.d : 이 위치에 모듈을 추가함으로써 아파치 웹 서버를 확장시킬 수 있다.

 

/www/docs/account.example.com/index.html  : 각 웹 서버 별 웹 페이지 저장 공간 (물론 /www/docs는 아파치 ㅅ버버 메인 구성 파일에서 변경할 수 있는, 즉, 사용자가 지정한 공간)

/www/docs/sales.example.com/index.html 

 

 

아파치 서버 구성

 

1. 아파치 서버 및 관련 패키지 설치 

# yum install httpd

# yum groups install “Basic Web Server”

 

2. 예시로 아래와 같이 호스트 파일에서 호스트 설정 (이 호스트는 이후에 IPA 서버 구성에서도 쓰임)

(참고로 앞으로 진행될 예시에서는 현재 구성중인 로컬 장비의 ip 주소는 192.168.122.210 입니다. 즉, server1에서 구축 진행중)

# vim /etc/hosts

 

        192.168.122.210 server1.example.com server1

192.168.122.220 server2.example.com server2

192.168.122.210 account.example.com account

12.168.122.210 sales.example.com sales

 

3. server1에서 호스트 account에 대한 아파치 구성 파일을 만듭니다.

# vim /etc/httpd/conf.d/account.example.com/account.example.com.conf

 

       <VirtualHost *:80>

ServerAdmin webmaster@account.example.com

DocumentRoot /www/docs/account.example.com

ServerName account.example.com

ErrorLog logs/account/example.com-error_log

CustomLog logs/account.example.com-access_log common

</VirtualHost>

 

4.  account 웹 서버를 구축할 디렉토리를 만듭니다.

# mkdir -p /www/docs/account.example.com

 

5. account 웹 서버의 index 파일을 생성하고 테스트 출력을 위해 "welcome to account를 입력"

# vim /www/docs/account.example.com/index.html

 

       welcome to account

 

 

6. 아파치 로그 폴더에 account 로그 파일을 생성합니다.

# mkdir -p /etc/httpd/logs/account

 

7. 잠시 SELinux를 꺼둡니다.

# setenforce 0

 

8. 아파치 서버를 재시작 합니다.

# systemctl restart httpd

 

9. 웹페이지에 정상적으로 wecome to account 메시지가 출력되는지 확인합니다.

# elinks http://account.example.com

 

10. sales 웹 페이지도 만들 경우, 위와 같은 방법으로 동일하게 만들되, account 와의 경로만 적절하게 분리해주면 됩니다. 그리고 나서 아파치 서비스를 재시작해주면 sales와 account 웹 서버 페이지가 별도로 생성되는 것을 확인할 수 있습니다. 


 


TAGS.

Comments