# Document Root

> The folder a web server hands out files from. Visitors see only what is in it.

**Field:** Infrastructure  
**Category:** Web Serving & Nginx  
**Also known as:** Web Root, Webroot, DocumentRoot

## Think of it like

It is like the shelf in a shop window. Only what is on that shelf can be seen from the street.

## Definition

The document root is the folder a web server serves files from. A web address maps onto a path inside it. If the root is /var/www/site, then /about.html is read from /var/www/site/about.html. Files outside that folder cannot be fetched by a visitor. In Nginx it is set with root, and in Apache with DocumentRoot.

## Example

Lucy's root is the shop folder. She puts logo.png in its images folder. It then shows at /images/logo.png on her site.

## Why it matters

It decides what the world can download. A file put there by mistake can be read by anyone.

## Common mistake

Keeping secret files, like a .env file or a backup, inside the document root. Anyone who guesses the name can download them.

## Three principles

- **One folder.** The web serves from here.
- **Paths map.** The web address follows the folders.
- **Public by default.** Assume anything inside is seen.

## Related terms

- [Web Server](https://learn.benibix.com/term/infrastructure/web-server)
- [Nginx Server Block](https://learn.benibix.com/term/infrastructure/nginx-server-block)
- [Apache HTTP Server](https://learn.benibix.com/term/infrastructure/apache-http-server)
- [Uniform Resource Locator (URL)](https://learn.benibix.com/term/general/url)
- [File System](https://learn.benibix.com/term/development/file-system)

![A browser on the left sends a request to a web server such as Nginx or Apache. The web server reads plain files straight from its document root folder, and passes every other request to an application server, which reads a database. Each request also adds one line to an access log file.](https://learn.benibix.com/diagrams/inf2-web-server.svg)

---

Source: https://learn.benibix.com/term/infrastructure/document-root
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
