본문 바로가기

Linux Server 구축/1-2. Web Server

Apache WebServer - Virtual Host - Mixed Name & IP-based


Virtual Host 참고사항 :
http://bban2.tistory.com/134

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

Virtual Host - Mixed Name & IP-based Virtual Host

1-1. Mixed Named & IP-based Virtual Host 설정

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf

990 NameVirtualHost 192.168.0.7:80

1012 <VirtualHost 192.168.0.7:80>
1013     ServerAdmin root@bban2.co.kr
1014     DocumentRoot /var/www/html
1015     ServerName www.bban2.co.kr
1016 </VirtualHost>                                    - Named-based Virtual Host
1017
1018 <VirtualHost 192.168.0.7:80>
1019     ServerAdmin root@bban2.co.kr
1020     DocumentRoot /www2
1021     ServerName www2.bban2.co.kr
1022 </VirtualHost>                                   - Named-based Virtual Host
1023
1024 <VirtualHost 10.10.33.3:80>            
1025     ServerAdmin root@bban2.co.kr
1026     DocumentRoot /www1
1027     ServerName www1.bban2.co.kr
1028 </VirtualHost>                                   -  IP-based Virtual Host

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

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

1-2. Forward Zone 파일 설정

[root@localhost ~]# vi /var/named//chroot/var/named/dns.for
[root@localhost ~]# cat /var/named//chroot/var/named/dns.for
$TTL    86400
@               IN SOA  bban2.co.kr. root.bban2.co.kr. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           bban2.co.kr.
                IN A            192.168.0.7
www             IN A            192.168.0.7
 
www1            IN A            10.10.33.3
www2            IN A            192.168.0.7

[root@localhost ~]# rndc reload
server reload successful

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

1-3. /www2 폴더 생성

[[root@localhost ~]# mkdir /www2
[root@localhost ~]# cd /www2
[root@localhost www2]# vi index.html
[root@localhost www2]# cat index.html
Hello!!
Here's www2.bban2.co.kr

Named-based Virtual Host

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

1-4. http 서비스 재시작

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

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

1-5. 웹브라우저에서 홈페이지 확인

[root@localhost network-scripts]# host www.bban2.co.kr
www.bban2.co.kr has address 192.168.0.7
[root@localhost network-scripts]# host www1.bban2.co.kr
www1.bban2.co.kr has address 10.10.33.3
[root@localhost network-scripts]# host www2.bban2.co.kr
www2.bban2.co.kr has address 192.168.0.7

www.bban2.co.kr


www1.bban2.co.kr


www2.bban2.co.kr