웹사이트 검색

Linux에서 Apache 문서 루트를 찾는 방법


DocumentRoot는 웹에서 볼 수 있는 문서 트리의 최상위 디렉터리이며 이 지시문은 Apache2 또는 HTTPD가 시작되는 구성의 디렉터리를 설정합니다. > 요청된 URL에서 문서 루트까지 웹 파일을 찾아 제공합니다.

예를 들어:

DocumentRoot "/var/www/html"

그런 다음 http://domain.com/index.html에 대한 액세스는 /var/www/html/index.html을 참조합니다. DocumentRoot는 뒤에 슬래시 없이 설명되어야 합니다.

이 짧은 팁에서는 Linux 시스템에서 Apache DocumentRoot 디렉토리를 찾는 방법을 보여줍니다.

Apache 문서 루트 찾기

Debian, Ubuntu LinuxLinux Mint와 같은 파생 제품에서 Apache DocumentRoot 디렉터리를 가져오려면 다음을 실행하세요. grep 명령.

grep -i 'DocumentRoot' /etc/apache2/sites-available/000-default.conf
grep -i 'DocumentRoot' /etc/apache2/sites-available/default-ssl.conf

CentOS, RHELFedora Linux 배포판에서는 다음 명령을 실행합니다.

grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf
grep -i 'DocumentRoot' /etc/httpd/conf.d/ssl.conf

DocumentRoot 디렉토리의 위치는 Apache 또는 httpd 구성에 설정된 DocumentRoot 지시문의 값에 따라 달라질 수 있습니다.

Apache DocumentRoot 디렉터리의 위치를 변경하려면 Linux에서 기본 Apache 'DocumentRoot' 디렉터리를 변경하는 방법을 설명하는 문서를 읽어보세요.

참고로 모든 가상 호스트의 개별 디렉토리는 DocumentRoot 아래에 있어야 합니다. 예를 들어, DocumentRoot/var/www/html이고 example1.comexample2라는 두 개의 사이트가 있는 경우. com에서 표시된 대로 디렉토리를 생성할 수 있습니다.

sudo mkdir -p /var/www/html/example1.com/
sudo mkdir -p /var/www/html/example2.com/

그런 다음 가상 호스트 구성 파일에서 DocumentRoot가 위 디렉터리를 가리키도록 합니다.

다음은 유용한 Apache 웹 서버에 대한 몇 가지 추가 가이드입니다.

  1. Linux에서 Apache 웹 서버를 관리하는 데 유용한 명령
  2. Linux에서 Apache 서버 상태 및 가동 시간을 확인하는 3가지 방법
  3. RHEL/CentOS에서 Apache Userdir 모듈을 활성화하는 방법
  4. Apache 가상 호스팅: IP 기반 및 이름 기반 가상 호스트
  5. Apache 웹 서버의 모든 가상 호스트를 나열하는 방법

그게 다야! Apache DocumentRoot 디렉토리를 찾는 다른 유용한 방법을 알고 있다면 아래 댓글 섹션에서 공유해 주세요.