# WEB | Apache

Apache V-host 설정

강냉:) 2024. 1. 23. 14:26

1. httpd-vhosts.conf 파일 Include

$ vi [Apache_install_dir]/conf/httpd.conf

 

# Include conf/extra/httpd-vhosts.conf -> 주석해제

 

2. vhost 설정파일 작성

$ vi /sw/web/apache2.4/conf/extra/httpd-vhosts.conf

 

# aaa.t.com 로 접속하면 /sw/web/apache2.4/webpage 디렉토리의 파일을 읽어서 응답한다는 뜻.
# VirtualHost 태그의 *은 IP를 의미하고 , NameVirtualHost에서 설정해준 IP와 동일하게 설정해야 한다. 

< VirtualHost *:80>
    DocumentRoot "/sw/web/apache2.4/webpage"
    ServerName aaa.t.com
    ErrorLog "logs/extralog/t.com-error_log"
    CustomLog "logs/extralog/t.com-access_log" common
   <Directory />
    Require all granted
   </Directory>
   JKMount /*.jsp lb
</VirtualHost>

# Require all granted 는 모든 엑세스의 접근을 허용하는 설정입니다.

 

3. DocumentRoot 에 index.html 파일 만들기

$ cd /sw/web/apache2.4/webpage

$ mkdir index.html

 

 

4. 로컬 DNS 등록

메모장의 [파일] – [열기]에서 ‘C:\Windows\System32\drivers\etc’ 경로의 ‘hosts’ 파일 열기

 

 

 

 

5. apache 서버 재기동 

 

$ ./[Apache_install_dir]/bin/apachectl restart

 

6. 페이지 호출