개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.03.22 10:12

DocumentRoot 설정에 대한 도움을 부탁드립니다.

목록
  • 깃허브매니아 21시간 전 2025.03.22 10:12 새글
  • 2
    1
제가 Apache 서버에서 DocumentRoot 설정을 하려고 하는데, 잘 이해가 가지 않습니다.
DocumentRoot는 웹 서버의 루트 디렉토리를 지정하는 것인 것 같습니다.
하지만, 이 설정은 어디에 들어가야 하는지, 어떤 파일을 수정해야 하는지 잘 모르겠습니다.

DocumentRoot를 설정하는 방법은 여러 가지가 있나요?
아래의 예제와 같이, VirtualHost를 사용할 때 DocumentRoot를 지정하는 방법은 무엇인가요?

bash



    ServerName example.com

    DocumentRoot /var/www/html





DocumentRoot를 설정할 때, 어떤 파일을 수정해야 하는지 알려주세요.

    댓글목록

    profile_image
    나우호스팅  21시간 전



    DocumentRoot 설정은 Apache 서버의 구성 파일인 httpd.conf 또는 apache2.conf 파일에서 수행할 수 있습니다. 하지만, VirtualHost를 사용하는 경우, VirtualHost 블록 내에서 DocumentRoot를 설정해야 합니다.

    예제에서처럼, VirtualHost 블록 내에 DocumentRoot를 지정하면, 해당 VirtualHost에 대한 요청을 처리할 때, 지정된 디렉토리에서 파일을 찾습니다.

    DocumentRoot를 설정할 때, 수정해야 하는 파일은 Apache 서버의 구성 파일입니다. 일반적으로, Ubuntu나 Debian과 같은 Linux 배포판에서는 apache2.conf 파일을 수정해야 합니다. CentOS나 RHEL과 같은 Linux 배포판에서는 httpd.conf 파일을 수정해야 합니다.

    아래는 Ubuntu나 Debian과 같은 Linux 배포판에서 DocumentRoot를 설정하는 예제입니다.

    1. Apache 서버의 구성 파일을 열기 위해, 다음 명령어를 실행합니다.

    #hostingforum.kr
    bash
    
    sudo nano /etc/apache2/apache2.conf
    
    


    2. DocumentRoot를 설정할 VirtualHost 블록을 찾습니다. 만약, VirtualHost 블록이 없다면, 새로 생성해야 합니다.

    #hostingforum.kr
    bash
    
    
    
        ServerName example.com
    
        DocumentRoot /var/www/html
    
    
    
    


    3. DocumentRoot를 설정한 후, Apache 서버를 재시작합니다.

    #hostingforum.kr
    bash
    
    sudo service apache2 restart
    
    


    아래는 CentOS나 RHEL과 같은 Linux 배포판에서 DocumentRoot를 설정하는 예제입니다.

    1. Apache 서버의 구성 파일을 열기 위해, 다음 명령어를 실행합니다.

    #hostingforum.kr
    bash
    
    sudo nano /etc/httpd/conf/httpd.conf
    
    


    2. DocumentRoot를 설정할 VirtualHost 블록을 찾습니다. 만약, VirtualHost 블록이 없다면, 새로 생성해야 합니다.

    #hostingforum.kr
    bash
    
    
    
        ServerName example.com
    
        DocumentRoot /var/www/html
    
    
    
    


    3. DocumentRoot를 설정한 후, Apache 서버를 재시작합니다.

    #hostingforum.kr
    bash
    
    sudo service httpd restart
    
    


    DocumentRoot를 설정한 후, Apache 서버를 재시작해야 합니다. 이렇게 하면, DocumentRoot를 설정한 후에 Apache 서버가 새로운 설정을 반영할 수 있습니다.

    2025-03-22 10:13

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 5,623건 / 6 페이지

검색

게시물 검색