본문 바로가기

Linux Server 구축/1-2. Web Server

Apache WebServer - Exercise 1

다음과 같이 웹서버를 구축하시오.

 Domain  IP  Documentroot
 spring.server3.co.kr  10.10.33.3  /spring
 summer.server3.co.kr  192.168.33.3  /summer
 fall.server3.co.kr  10.10.33.3  /fall
 winter.server3.co.kr  10.10.33.3:8080  /winter


-----------------------------------------------------------------------------------------------------

1. httpd.conf 파일 설정

[root@localhost~]# vi /etc/httpd/conf/httpd.conf
126 # Listen: Allows you to bind Apache to specific IP addresses and/or
127 # ports, in addition to the default. See also the <VirtualHost>
128 # directive.
129 #
130 # Change this to Listen on specific IP addresses as shown below to
131 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
132 #
133 #Listen 12.34.56.78:80
134 Listen 80
135 Listen 8080

1013 <VirtualHost 10.10.33.3:80>
1014     ServerAdmin root@server3.co.kr
1015     DocumentRoot /spring
1016     ServerName spring.server3.co.kr
1017 </VirtualHost>
1018
1019 <VirtualHost 192.168.33.3:80>
1020     ServerAdmin root@server3.co.kr
1021     DocumentRoot /summer
1022     ServerName summer.server3.co.kr
1023 </VirtualHost>
1024
1025 <VirtualHost 10.10.33.3:80>
1026     ServerAdmin root@server3.co.kr
1027     DocumentRoot /fall
1028     ServerName fall.server3.co.kr
1029 </VirtualHost
1030
1031 <VirtualHost 10.10.33.3:8080>
1032     ServerAdmin root@server3.co.kr
1033     DocumentRoot /winter
1034     ServerName winter.server3.co.kr
1035 </VirtualHost>

-----------------------------------------------------------------------------------------------------

2. Forward Zone 파일 설정

[root@localhost network-scripts]# vi /var/named/chroot/var/named/server3.zone
[root@localhost network-scripts]# cat /var/named/chroot/var/named/server3.zone
1 $TTL    86400
2 @               IN SOA  server3.co.kr. root.server3.co.kr. (
3                                         42              ; serial (d. ada        ms)
4                                         60              ; refresh
5                                         15M             ; retry
6                                         1W              ; expiry
7                                         1D )            ; minimum
8                 IN NS           server3.co.kr.
9                 IN A            10.10.33.3
10 spring          IN A            10.10.33.3
11 summer          IN A            192.168.33.3
12 fall            IN A            10.10.33.3
13 winter          IN A            10.10.33.3

[root@localhost network-scripts]# rndc reload
server reload successful

-----------------------------------------------------------------------------------------------------

3. 폴더 및 index.html파일 생성

[root@localhost ~]# mkdir /spring
[root@localhost ~]# mkdir /summer
[root@localhost ~]# mkdir /fall
[root@localhost ~]# mkdir /winter
[root@localhost ~]# cd /spring
[root@localhost spring]# vi index.html
[root@localhost spring]# cat index.html
spring!!

[root@localhost spring]# cp index.html /summer/
[root@localhost spring]# cp index.html /fall/
[root@localhost spring]# cp index.html /winter/
[root@localhost spring]# cd /summer
[root@localhost summer]# vi index.html
[root@localhost summer]# cat index.html
Summer!!

[root@localhost summer]# cd /fall
[root@localhost fall]# vi index.html
[root@localhost fall]# cat index.html
Fall!!

[root@localhost fall]# cd /winter
[root@localhost winter]# vi index.html
[root@localhost winter]# cat index.html
Winter!!

-----------------------------------------------------------------------------------------------------

4. httpd 서비스 재시작

[root@localhost ~]# httpd -t
Syntax OK

[root@localhost ~]# service httpd restart
httpd 를 정지 중:                                          [  OK  ]
httpd (을)를 시작 중:                                      [  OK  ]

-----------------------------------------------------------------------------------------------------

5. 확인

[root@localhost winter]# host 10.10.33.3
3.33.10.10.in-addr.arpa domain name pointer server3.co.kr.
3.33.10.10.in-addr.arpa domain name pointer www.server3.co.kr.
[root@localhost winter]# host spring.server3.co.kr
spring.server3.co.kr has address 10.10.33.3
[root@localhost winter]# host summer.server3.co.kr
summer.server3.co.kr has address 192.168.33.3
[root@localhost winter]# host fall.server3.co.kr
fall.server3.co.kr has address 10.10.33.3
[root@localhost winter]# host winter.server3.co.kr
winter.server3.co.kr has address 10.10.33.3

웹브라우저에서 확인

spring.server3.co.kr
summer.server3.co.kr
fall.server3.co.kr
winter.server3.co.kr