Web servers and static sites
Quick answer
A web server accepts HTTP requests and can map URL paths to files under a document root. Nginx and Apache are common choices.
Map a request path to the configured document root. A server may return a successful response for one file and a not-found or forbidden response for another. Verify the expected body and status for known, missing and restricted paths using a private test service.
Prepare the practice environment
Run python3 lab-fixtures/servers/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Only local loopback services and private files are used. Optional examples require an authorized snapshot VM. Never expose a lab listener publicly or modify system services. Review the lab guide.
How it works
The listener binds an address and port; virtual hosts select configuration using the requested host and other rules. A document root defines the file tree used for static responses. An index file can represent a directory URL; missing resources typically return 404. Restrict document roots to publishable files and grant only necessary read and traversal permissions. Nginx uses server/location blocks; Apache uses directives such as DocumentRoot and VirtualHost. The fixture provides a standalone Nginx configuration and a Python helper that starts a short-lived loopback-only server to serve synthetic content. The Apache fixture targets Debian module paths; adapt on a separate VM for other distributions. Syntax tests do not establish production readiness.
Try the examples
The document contains only synthetic public content. Never place credentials or private configuration in this root.
Expected stdout:
<h1>ByteMind lab</h1>The helper runs nginx -t with a private prefix and explicit configuration, without starting or reloading a system service.
Expected stdout:
nginx configuration validA temporary Python HTTP listener serves only the lab site. The helper uses curl with bounded timeouts and checks both status and content. This tests HTTP behavior, not Nginx runtime.
Expected stdout:
HTTP 200: ByteMind labHTTP 404 detectedCommon mistakes
Never use a broad directory such as your home as a public document root. Do not use chmod 777 to repair a web permission problem.
Practice
In a fresh fixture, add a second harmless HTML file. Explain how its URL maps to the document root and predict a request for a missing file. In a disposable VM, validate the supplied configuration before any service change.
Related references
Study: nginx, apache2, curl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Web servers and static sites — Knowledge Check
Apply hosting and deployment concepts to synthetic fixtures and VM-only scenarios.
What does a document root define?
What usually indicates a missing HTTP resource?
Does nginx -t prove the site is reachable?
Which files belong in a public root?