
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