Skip to content
BENIBIX Learn

Document Root

Infrastructure🌍 Web Serving & NginxServer Configuration

Also known as Web Root, Webroot, DocumentRoot

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

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.

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.

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.
The document root is the folder of files under the web server. Anything in it can be fetched.

Common mistake

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

Key takeaways

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