WAMP 및 dnsmasq를 사용하여 로컬 하위 도메인을 매핑하는 방법

WAMP 및 dnsmasq를 사용하여 로컬 하위 도메인을 매핑하는 방법

로컬 장치를 네트워크의 간단한 경로에 매핑하기 위해 로컬 Raspberry Pi 상자에 DnsMasq 설정이 있습니다(예: laptop.local). 저는 로컬 웹 개발을 위해 랩톱에서 WAMP를 사용하고 있으며 이 설정은 매우 잘 작동합니다. 교육 목적으로, 내 노트북의 하위 디렉터리(현재 "laptop.local/website")를 "website.laptop.local" 대신 하위 도메인에 매핑하려면 어떻게 해야 합니까?

답변1

DNS가 올바르게 설정되었다고 가정합니다.노트북.로컬, 적절한 Apache 가상 호스트를 사용하려면 WAMP 구성만 업데이트하면 됩니다.

WAMP 구성

  1. 하위 도메인을 보관할 디렉터리를 만듭니다. WAMP 설치가 액세스할 수 있는 위치(예: 루트 www폴더 아래 또는 옆)에서 이 작업이 수행되었는지 확인하십시오.

  2. 아파치 열기httpd.conf(Apache conf디렉토리 아래의 WAMP 설치 또는 적절한 메뉴 인터페이스(예: )를 통해 위치 Apache → httpd.conf).

  3. 이 줄의 주석 처리를 해제합니다(# 제거).

     # Include conf/extra/httpd-vhosts.conf 
    

    그러면

     Include conf/extra/httpd-vhosts.conf
    
  4. Apache conf\extra폴더를 열고 httpd-vhosts.conf. 파일 끝에 다음과 유사한 내용을 추가합니다.

    # Virtual host entry for website.laptop.local
    # Anything with a # is a comment
    
    <VirtualHost *:80>
    
    ServerName website.laptop.local
    #ServerAlias *.website.laptop.local
    
    # DocumentRoot should correspond to wherever the HTML files
    # for your website.laptop.local site are located. This is an example!
    
    DocumentRoot "C:/wamp/www/subdomains/my-website"
    
    ErrorLog "logs/my-website-error.log"
    CustomLog "logs/my-website-access.log" common
    
    # If you have any problems with "Forbidden", try uncommenting
    # the following (assumes Apache 2.4.x).
    
    #<Directory "C:/wamp/www/subdomains/my-website">
    
         #AllowOverride None
         #Options None
         #Require all granted
    
    #</Directory>
    
    </VirtualHost>
    
  5. 활성화했는지 확인하세요.별칭_모듈그리고vhost_alias_module아파치 모듈. 일반적으로 이 작업은 적절한 메뉴 인터페이스를 통해 (다시) 수행되지만 잠재적 으로 해당 모듈 행의 주석 처리를 제거하여 Apache → Apache modules수행할 수도 있습니다 .httpd.conf

  6. WAMP 서버를 다시 시작하세요.

오류가 없다고 가정하면,웹사이트.노트북.로컬이제 사용할 수 있습니다.

관련 정보