Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 |
Tags
- 중원대
- 한국교통안전공단
- 항산화
- 건강
- 이륜차
- 워터피아
- 네트워크
- 로ㅓ
- 잠 잘자는법
- 쉽게 배우는 데이터 통신과 컴퓨터 네트워크
- 찬용티비 구독점 ㅋ
- 앙 기모띠 ㅋ
- 물놀이
- 데이터 통신과 컴퓨터 네트워크
- 노화예방
- 잠자기
- 면역력
- 이륜차 교육
- 충청도
- 비타민C
- 수면의 중요성
- 식습관
- 괴산
- 수면
- 잠 잘오는 법
- 워터파크
- 데이터 통신과 컴퓨터 네트워크 답
- 괴산놀거리
- 바이크입문 #CB125R #혼다CB125R #125cc추천 #네이키드바이크 #중고바이크 #청주바이크
- 가족여행
Archives
- Today
- Total
chanYongYong
[xampp] 가상 호스트 사용법 (내부망) 본문
1. 내 PC에서만 쓸 때: hosts + .test
프로젝트별로 주소를 정함
launcher.test
manage.test.hi
home
(주소에 .com .test .a.b 등 뭐가 들어와서 상관 X)
Windows의 다음 파일에:
C:\Windows\System32\drivers\etc\hosts
아래처럼 등록
127.0.0.1 launcher.test
127.0.0.1 manage.test.hi
127.0.0.1 home
그리고 C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
ServerName launcher.test
DocumentRoot "C:/xampp/htdocs/launcher"
<Directory "C:/xampp/htdocs/launcher">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName manage.test.hi
DocumentRoot "C:/xampp/htdocs/manage"
<Directory "C:/xampp/htdocs/manage">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName home
DocumentRoot "C:/xampp/htdocs/home"
<Directory "C:/xampp/htdocs/home">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
이제 이렇게 바로 접속 가능
http://launcher.test
http://manage.test.hi
http://home
2. 내부망의 몇 대만 쓸 때
서버 PC의 내부 IP가 192.168.0.20이라고 가정하면, 접속할 PC들의 hosts 파일에 다음과 같이 입력 후 저장
C:\Windows\System32\drivers\etc\hosts
192.168.0.20 launcher
192.168.0.20 manage
(마찬가지로 주소에 .com .test .a.b 등 뭐가 들어와서 상관 X)
서버의 Apache에는:
<VirtualHost *:80>
ServerName launcher
DocumentRoot "C:/xampp/htdocs/launcher"
<Directory "C:/xampp/htdocs/launcher">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName manage
DocumentRoot "C:/xampp/htdocs/manage"
<Directory "C:/xampp/htdocs/manage">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
그러면 내부 PC에서:
http://launcher
http://manage
로 접속.
몇 대까지는 이 방식이 편함
- 1대: 내 PC의 hosts만 수정
- 2~5대: 각 PC의 hosts 수정
- PC가 많거나 IP가 자주 바뀜: 내부 DNS 서버 사용
내부 DNS를 쓰면 접속 PC마다 hosts 파일을 수정할 필요 없이 DNS 한 곳에만 등록하면 됨.
3. 기본 가상 호스트를 차단용으로 만들기
Apache는 입력된 주소가 어떤 ServerName과도 일치하지 않으면 첫 번째 가상 호스트를 기본 사이트로 사용.
따라서 첫 번째에 실제 사이트가 아닌 차단용 가상 호스트를 두면, 타 사이트와 헷갈리지 않음
!꼭 맨 첫번째로 default가 와야 함
<VirtualHost *:80>
ServerName default.invalid
DocumentRoot "C:/xampp/htdocs/_blocked"
<Directory "C:/xampp/htdocs/_blocked">
Require all denied
</Directory>
</VirtualHost>