웹서버/Apache

[설정] 가상호스트(VirtualHost) 설정

투칼론 2016. 5. 27. 08:01
반응형

1. httpd.conf 파일 수정


# Virtual hosts 설정되도록 주석 제거


[변경 전]

#Include conf/extra/httpd-vhosts.conf 


[변경 후]

Include conf/extra/httpd-vhosts.conf 

 



2. httpd-vhosts 파일에 설


설정파일 예 : /apache2/conf/extra/httpd-vhosts.conf


아래와 같이 가상호스트를 설정한다


# 모든 IP의 80 포트에서 요청을 기다림

NameVirtualHost *:80


<VirtualHost *:80>

    DocumentRoot /www/example1

    ServerName www.example.com

    ErrorLog "logs/example1-error.log"

    CustomLog "logs/example1-access.log" common

</VirtualHost>


<VirtualHost *:80>

    DocumentRoot /www/example2

    ServerName www.example.org

    ErrorLog "logs/example1-error.log"

    CustomLog "logs/example1-access.log" common 

</VirtualHost> 



관리편의상 Vhost 마다 DocumentRoot, ErrorLog, CustomLog 경로를 별도로 설정해준다.