질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

아파치 virtual host 설정

작성자 정보

  • 유진 작성
  • 작성일

컨텐츠 정보

본문

CentOS5에 Apache 2.2.6을 설치하였습니다...

가상호스트를 설정했는데 무조건 특정 호스트로만 연결이 되네요..

# AAAA Web

DocumentRoot "/home/AAAA"
ServerName 220.xxx.xxx.xxx

allow from all
Options +Indexes

# BBBB Web

DocumentRoot "/home/BBBB"
ServerName BBBB.co.kr

#allow from all
Options +Indexes

# CCCC Web

DocumentRoot "/home/CCCC"
ServerName CCCC.co.kr

allow from all
Options +Indexes

# DDDD Web

DocumentRoot "/home/DDDD"
ServerName DDDD.me

allow from all
Options +Indexes


여기서 DDDD.me를 브라우저로 연결하면 BBBB.co.kr로 연결됩니다.
(참고로 첫번째 것은 아이피에 포트 붙여서 불러옵니다.)

관련자료

댓글 2

최훈님의 댓글

  • 최훈
  • 작성일
NameVirtualHost 192.168.117.232:80

<VirtualHost 192.168.117.232:80>
ServerAdmin admin@example.co.kr
DocumentRoot /home/web/www.example.co.kr
ServerName www.example.co.kr

ServerAlias *.example.co.kr example.co.kr <<------- 이부분 * 추가 해주세요

ErrorLog /home/web/logs/example.co.kr-error_log
CustomLog /home/web/logs/example.co.kr-access_log common
</VirtualHost>

저도 하루날새고 삽질하다 상사분에게 물어보니까.. 간단하게 답변해주시더라구요^^;

유진님의 댓글

  • 유진
  • 작성일
답변 감사합니다~

아이피:포트, example1, example2 이렇게 3가지로 설정할때 문제가 있습니다.
첫번째 아이피:포트는 Listen에서 지정, iptables에서 포트를 열어주었는데 처음 세팅시 포트만 인식하네요...

두번째 example1은 접속이 잘됩니다...

세번재 example2는 example1로 접근 됩니다.(알려주신 ServerAlias 써봤는데 안되네요.)

마지막 번외인데,,Virtual에 도메인을 입력하면 0번 포트 중복이라 뜨고, 도메인:80, *:80, 아이피:80 이렇게는 중복되었다고 뜨네요.. 뭐가 문제인지..

아래 사용된 설정값 입니다.

# IpSet Web
<VirtualHost 192.168.231.196:8001>
DocumentRoot "/home/ipSet"
ServerName 192.168.231.196
<Directory "/home/ipSet">
    Options None
    Order allow,deny
    Allow from all
    Order allow,deny
</Directory>
</VirtualHost>

# example1 Web
<VirtualHost www.example1.me:80>
DocumentRoot "/home/example1"
ServerName www.example1.me
ServerAlias *.example1.me
<Directory "/home/example1">
    Options None
    Order allow,deny
    Allow from all
    Order allow,deny
</Directory>
</VirtualHost>

# example2 Web
<VirtualHost www.example2.me:80>
DocumentRoot "/home/example2"
ServerName www.example2.me
ServerAlias *.example2.me
<Directory "/home/example2">
    Options None
    Order allow,deny
    Allow from all
    Order allow,deny
</Directory>
</VirtualHost>

공지사항


뉴스광장


  • 현재 회원수 :  60,043 명
  • 현재 강좌수 :  35,853 개
  • 현재 접속자 :  72 명