Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 8: Configuring Nginx and Apache

AWS Cloud

8.5 Task: change the Apache DocumentRoot

When you move an Apache DocumentRoot, check the policy that applies to the new disk directory. Move an old path-specific <Directory> rule when the new path needs that policy. An inherited rule may already apply, so a 403 depends on the effective configuration.

Identify the named virtual host and its currently included configuration file. Prepare the new content and save a protected backup outside the include patterns. Adjust the mapping and applicable public directory policy only for that site.

# Illustrative directives inside the intended virtual host.
DocumentRoot "/var/www/portfolio"
<Directory "/var/www/portfolio">
    Options -Indexes
    AllowOverride None
    Require all granted
</Directory>

This small example grants public access only within the approved portfolio directory. Preserve any narrower restrictions and required application policy from the current site. Package filenames, inherited directory grants and service activation commands vary. Check the exact config and host report before activation, then compare the intended hostname, public files and independent virtual-host control.

Ravindra Bagale's Tip

For a 403, trace the exact request and inspect the relevant Apache error log. Check the mapped file, the effective directory and authorization rules, worker access to its parents, and any enforcing host policy. Use namei -l on Linux to inspect path components. A forbidden directory index can also return 403.

Lab

Use the isolated exercise below to observe the old directory, a mapping-only denial, the scoped policy repair and rollback. Keep the intentionally denied step inside the disposable loopback instance.

Move the site's files without moving its web address

A small design studio runs a public portfolio and an independent library on the same Apache server. The team builds a new portfolio theme in a fresh directory to keep the earlier release available. Visitors already have links to the portfolio address and its sample gallery. The owner wants those links to keep working after the switch. Both releases are ordinary files, prepared ahead of time, so the Apache change is to select the new directory for ordinary file requests. The new files also need the intended access policy. A successful configuration check alone does not prove that visitors can open them.

The DocumentRoot directive identifies the starting directory for the site's ordinary static file lookup. With DocumentRoot set to /srv/portfolio/release-one, an ordinary request for /works/gallery.html selects the candidate at /srv/portfolio/release-one/works/gallery.html. After a switch to release-two, the same address and URL path can select the file in that directory instead. The mapping does not copy content. The target tree must be prepared with every required file before the configuration points there. A request to the root slash can also need a directory index, a file such as index.html that provides a default response for a directory URL.

Apache also needs to decide whether the resource can be served. A Directory section applies settings to the named filesystem directory and ordinarily the paths beneath it. The site can have an explicit rule giving public access to the existing root. After the mapping moves, that particular Directory rule keeps describing the old disk path until its scope changes. Depending on other applicable sections, a broader grant could still allow the new path, a broader deny could prevent it, or unrelated settings could apply. Check the effective policy before changing a path. The presence of two occurrences of an old string is a clue, not an instruction to replace them everywhere.

The important distinction is between lookup and authorization. The DocumentRoot answers where the server should look for a normal request. The Directory rules contribute to deciding what the requester may access there, which options apply, and whether a separate configuration file can override the rules. Operating-system permissions and applicable host policies constrain the actual read as well. All these decisions can be correct for one directory and wrong for another. This lesson uses a small controlled example in which a site-wide default denies the filesystem and an explicit site setting grants the public path. It deliberately changes one input incorrectly first, records the resulting 403, then repairs the matching rule.

Do the intentional failure only in the disposable exercise. On a shared or public service, stage mapping and matching policy together and use a preproduction test or approved release workflow. The point of isolating the failure is that the concept becomes observable without interrupting another site's users. The previous lesson on reading Apache configuration describes how the listener, host and filesystem scopes fit together. Begin here with the real input, expected body and configuration selected for the host you plan to move.

Build a path and policy map for the target virtual host

A virtual host is Apache's set of instructions for a particular site that can share a server and listener with other sites. Its name is selected after the local address and port identify an eligible group. Obtain the site's parsed host definition using the active configuration and the appropriate startup options. Confirm the hostname you will put in your request, the document directory and its relevant Directory scope. Be particularly careful with sites that share a service's default host. Opening the bare IP often requests a different authority and can return the first applicable virtual host with a perfectly valid response. That result is a control, not verification of your named site.

Do not confuse Apache's ServerRoot with DocumentRoot. ServerRoot is a base from which the server can resolve relative paths for elements such as configuration and logs. A relative DocumentRoot may be interpreted relative to that server root. An explicit absolute directory avoids making you guess what a relative path will use. A Directory section names an actual applicable directory path. Quoting a path when showing it in Apache configuration is appropriate, especially when a path includes spaces. Your notes should identify separately the program instance, entry file and include, host name, old document directory and new document directory.

A global directive can apply to more than one site, even when the original package layout places it near the definition of a default public directory. Work within the named virtual host for this exercise. Apply only the narrow Directory allowance required for that virtual host to request its public content. Preserve restrictive defaults outside that path. If a shared rule grants everything under a parent directory, adding a new path beneath it may inherit more permissions than you expected. If there is a global deny and only the old public directory has an exception, the new path might be fully readable by the operating system yet still unavailable through Apache. Neither situation is settled by a filename comparison.

Build the list of rules that has to travel with the content. An index declaration can apply at site or directory level. Options controlling automatic directory listing may be inherited or set at the public scope. AllowOverride governs whether directory override files are eligible. A Files section may protect a reserved filename within a larger public directory. A Location section can constrain a URL area independently of the selected filesystem directory. An alias can point outside the root entirely. Evaluate whether each rule should follow the moved content, stay with a different mapped location, or remain in a global scope. A copy-and-replace of an entire configuration could inadvertently expose reserved resources or redirect unrelated paths.

Verification worksheet for the named portfolio site
RequestOriginal releaseAfter a complete moveReason for testing
portfolio.test /200 and original home marker200 and new home markerChecks directory index and active release
portfolio.test /works/gallery.html200 and original gallery200 and new galleryChecks a direct file inside the release
portfolio.test /works/staff.txt403403Checks the reserved filename rule travels with the public scope
portfolio.test /works/missing.html404404Checks the intended absence of a resource
library.test /200 and library markerSame 200 and markerChecks the independent virtual host

Use the report to predict the consequence of an incomplete change. If the new DocumentRoot selects a real new gallery file but the only allow rule still names the old folder, the lab's broader deny applies to the new folder. The response should be 403 even though the file exists and the grammar is valid. A syntax test is designed to check the candidate configuration, not interpret your desired permission policy. Bringing the existing narrow Directory section and reserved-file policy over to the new folder repairs the intended access. Verify that successful paths and intentional refusals both match the plan.

Prepare a candidate your team can restore and audit

Choose a dedicated document directory containing only the bytes intended to be public. Keep repositories, private keys, credentials, backups and admin files outside that tree. Build the site under the new named release folder, confirm the homepage, styles, images and public downloads are present, and write down the small set of paths on which visitors depend. In the real service, verify worker traversal of the parents and read access to the files; a public static process normally does not need permission to modify them. Avoid creating a broad allowance to a shared parent when granting only the new content path would be sufficient.

To understand ordinary Linux permissions, examine the account and group the worker uses. Access to an existing file requires search permission on every containing directory, then read access to the file. Search and listing are distinct. A directory with restrictive listing can still allow traversal to a known filename depending on the applicable mode and identity. A path that looks conventional may also be subject to an access list or enforcing security policy. Exact numeric modes such as 644 and 755 are examples used on some public trees, not requirements for every file and ancestor. Determine the minimum access the actual worker needs and verify a representative request once configuration is applied.

If SELinux is enforcing on your Linux distribution, inspect the label and relevant policy evidence for the exact path. A custom path can need a persistent content context assignment. The existing labels and active server domain tell you whether that is the problem. A config denial can look like a filesystem denial because both may surface as 403. Check Apache's error log and its site authorization before changing permissions. This local lab runs as one regular user and simulates a scoped Apache authorization failure. It does not reproduce every production identity, policy or filesystem mount.

Store a verified copy of the active virtual host in a private backup location outside every applicable include. Record any separate link used to enable it, plus the old content directory and operational dependencies. A backup of the old text cannot restore files that were deleted after the move. If the deployment uses builds, identify their revisions and keep the old artifact recoverable. Prepare a reversal of the smallest complete change, namely one site mapping and the policy that applies at the new mapping. Provide a deliberate validation signal that tells you when to restore. In this exercise, an unexpected denied public gallery or a mistakenly available reserved filename is a reason to reject the candidate.

Distinguish validating the candidate from activating it. A correctly invoked Apache syntax test reads the candidate text and can report some path or module problems. Its positive result is not a test of the particular URL, proof of effective authorization, or proof that the running instance has reloaded. A graceful restart asks the parent process to read the updated configuration while supporting completion of requests already being served. Verify actual behavior from a new controlled request after activation. A supported system service normally defines how to perform this operation. The lab sends a signal only to its own identified child so you can inspect the full cycle without editing a package file or restarting the system service.

Create measurable release and authorization controls

Use a disposable Bash shell as a regular user with Apache 2.4, curl and Python 3 installed. The exercise uses the high loopback port 18885, two site files and separate folders under a newly generated temporary directory. Replace that port everywhere if it is already occupied. This lab runs one private instance and needs no public listener, DNS change, package install, system service change or root access. Follow the blocks in one shell. The process identifier stored there links diagnosis and cleanup to the private instance you actually started.

Begin with files that unmistakably identify a site and release. The same relative gallery path exists in both roots, but the bytes differ. The lower-risk way to test protection is to use synthetic content in the reserved filenames. Both releases contain one such marker so a post-change 403 demonstrates a preserved authorization choice rather than a coincidental missing file. The independent library folder carries a marker that should not change at any step. The cleanup handler exits the private instance and removes the matching generated directory.

if [ "$(id -u)" -eq 0 ]; then
  printf 'Use a regular practice account.\n' >&2
  exit 1
fi
apache_bin=$(command -v apache2 || command -v httpd) || exit 1
ap_lab=$(mktemp -d /tmp/rb-apache-roots.XXXXXX) || exit 1
lab_pid=
apache_root_cleanup() {
  if [ -n "$lab_pid" ] && kill -0 "$lab_pid" 2>/dev/null; then
    kill "$lab_pid"
    wait "$lab_pid" 2>/dev/null || :
  fi
  case "$ap_lab" in
    /tmp/rb-apache-roots.??????) rm -r -- "$ap_lab" ;;
  esac
}
trap apache_root_cleanup EXIT
mkdir -p "$ap_lab/first/works" "$ap_lab/second/works" \
  "$ap_lab/library" "$ap_lab/sites" "$ap_lab/backups" "$ap_lab/logs"
printf 'portfolio-first-home\n' > "$ap_lab/first/index.html"
printf 'portfolio-second-home\n' > "$ap_lab/second/index.html"
printf 'portfolio-first-gallery\n' > "$ap_lab/first/works/gallery.html"
printf 'portfolio-second-gallery\n' > "$ap_lab/second/works/gallery.html"
printf 'reserved-fixture\n' > "$ap_lab/first/works/staff.txt"
printf 'reserved-fixture\n' > "$ap_lab/second/works/staff.txt"
printf 'library-control\n' > "$ap_lab/library/index.html"

Now find the Apache modules used by the example. Apache packages commonly split modules into shared libraries, which are loaded separately, and modules compiled into the executable. The writer only loads modules that the installed binary needs as separate components. If your package stores them elsewhere, find the real installation path before continuing. The main configuration is purposefully small. It denies general filesystem access and includes only the active site directory. In particular, the backup directory is outside the rule. The generated files use absolute paths tied to this lab.

module_dir=
for candidate in /usr/lib/apache2/modules /usr/lib64/httpd/modules /usr/lib/httpd/modules /usr/libexec/apache2; do
  if [ -r "$candidate/mod_dir.so" ] && [ -r "$candidate/mod_authz_core.so" ]; then
    module_dir=$candidate
    break
  fi
done
if [ -z "$module_dir" ]; then
  printf 'Locate the Apache package module directory before continuing.\n' >&2
  exit 1
fi
compiled=$("$apache_bin" -l) || exit 1
add_module() {
  local name=$1
  if ! printf '%s\n' "$compiled" | grep -Eq "(^|[[:space:]])mod_${name}\.c$"; then
    test -r "$module_dir/mod_$name.so" || return 1
    printf 'LoadModule %s_module "%s/mod_%s.so"\n' "$name" "$module_dir" "$name"
  fi
}
{
  printf 'ServerRoot "%s"\n' "$ap_lab"
  if ! printf '%s\n' "$compiled" | grep -Eq '(^|[[:space:]])(event|worker|prefork|mpm_event|mpm_worker|mpm_prefork)\.c$'; then
    add_module mpm_event || exit 1
  fi
  add_module unixd || exit 1
  add_module authz_core || exit 1
  add_module dir || exit 1
  add_module log_config || exit 1
  cat <<APACHE
ServerName main.test
Listen 127.0.0.1:18885
User "#$(id -u)"
Group "#$(id -g)"
PidFile "$ap_lab/apache.pid"
DefaultRuntimeDir "$ap_lab"
ErrorLog "$ap_lab/logs/main-error.log"
LogFormat "%v %f %>s" roots
<Directory />
    AllowOverride None
    Require all denied
</Directory>
Include "$ap_lab/sites/*.conf"
APACHE
} > "$ap_lab/httpd.conf"
cat > "$ap_lab/sites/000-library.conf" <<APACHE
<VirtualHost 127.0.0.1:18885>
    ServerName library.test
    DocumentRoot "$ap_lab/library"
    DirectoryIndex index.html
    <Directory "$ap_lab/library">
        Require all granted
    </Directory>
</VirtualHost>
APACHE
cat > "$ap_lab/sites/010-portfolio.conf" <<APACHE
<VirtualHost 127.0.0.1:18885>
    ServerName portfolio.test
    DocumentRoot "$ap_lab/first"
    DirectoryIndex index.html
    <Directory "$ap_lab/first">
        Options -Indexes
        AllowOverride None
        Require all granted
        <Files "staff.txt">
            Require all denied
        </Files>
    </Directory>
    ErrorLog "$ap_lab/logs/portfolio-error.log"
    CustomLog "$ap_lab/logs/portfolio-access.log" roots
</VirtualHost>
APACHE
cfg() {
  "$apache_bin" -f "$ap_lab/httpd.conf" "$@"
}
cfg -t || exit 1
cfg -S || exit 1

The new site config initially specifies the first folder twice for different reasons. The document directive maps the requests for the site. The Directory section sets the allow rule and includes a Files denial for its staff filename. The two separate directory exceptions cover only the library and original portfolio. The rest of the filesystem remains denied by the global rule. The host report should identify library and portfolio on the private address and port. A successful config test at this point confirms grammar and references visible to that test, and gives you a known-good candidate for the next steps.

"$apache_bin" -f "$ap_lab/httpd.conf" -DFOREGROUND &
lab_pid=$!
for attempt in 1 2 3 4 5 6 7 8 9 10; do
  if [ -s "$ap_lab/apache.pid" ]; then break; fi
  if ! kill -0 "$lab_pid" 2>/dev/null; then break; fi
  sleep 0.2
done
if ! kill -0 "$lab_pid" 2>/dev/null ||
   [ ! -s "$ap_lab/apache.pid" ] ||
   [ "$(tr -d '[:space:]' < "$ap_lab/apache.pid")" != "$lab_pid" ]; then
  printf 'The isolated listener could not start. Check the port and private log.\n' >&2
  if [ -r "$ap_lab/logs/main-error.log" ]; then
    tail -n 10 "$ap_lab/logs/main-error.log" >&2
  fi
  exit 1
fi

The foreground option keeps the Apache parent attached to the child launched by Bash. The shell backgrounds that child explicitly, then compares its identifier with the PID written inside the private directory. In particular, a process already occupying the port cannot pass as the experiment. If about two seconds elapse and the new process has not initialized, stop and read the relevant output. Because every diagnostic command receives the private path, there is no reason to signal or reload any existing Apache service.

probe() {
    local name=$1 path=$2 status
    status=$(curl --noproxy '*' --max-time 5 -sS \
      --resolve "$name:18885:127.0.0.1" -o "$ap_lab/probe.body" -w '%{http_code}' \
      "http://$name:18885$path") || return
    printf '%s %s HTTP %s\n' "$name" "$path" "$status"
    head -c 110 "$ap_lab/probe.body"
    printf '\n'
}
probe portfolio.test /
probe portfolio.test /works/gallery.html
probe portfolio.test /works/staff.txt
probe portfolio.test /works/missing.html
probe library.test /

Before proceeding, match the first home, first gallery and library markers. They should arrive with HTTP 200. The staff filename should be denied, and the missing asset should return 404 as planned. Confirm that the file intended to prove a specific authorization decision actually exists in both release directories. When you later see a 403 for staff, that will be a useful security control. If all content is absent, a 404 does not establish that a denial rule remains active. If all tests targeted a default host, even a green homepage would fail to identify the desired site.

Observe a root-only failure, then move the directory policy

Save the portfolio's active file and compare the copy. This first version is your true rollback state. Then change only the mapping in the temporary lab. The command below reads the preserved old reference and names the single complete line expected to be present. It preserves every other directive, including the narrower Directory section and its staff rule. The syntax check should succeed. The site remains on the same listener. This controlled change lets you prove the effect of a valid mapping paired with the old authorization scope.

site_file="$ap_lab/sites/010-portfolio.conf"
saved_file="$ap_lab/backups/portfolio-before.conf"
cp -p -- "$site_file" "$saved_file" || exit 1
cmp "$site_file" "$saved_file" || exit 1
change_line() {
  python3 - "$site_file" "$1" "$2" <<'PY'
from pathlib import Path
import sys

config = Path(sys.argv[1])
before, after = sys.argv[2] + "\n", sys.argv[3] + "\n"
text = config.read_text()
if text.count(before) != 1:
    raise SystemExit("Expected a single exact directive to update")
config.write_text(text.replace(before, after))
PY
}
review_diff() {
  local result
  if diff -u "$saved_file" "$site_file"; then
    printf 'No candidate change found.\n' >&2
    return 1
  else
    result=$?
    test "$result" -eq 1
  fi
}
change_line "    DocumentRoot \"$ap_lab/first\"" "    DocumentRoot \"$ap_lab/second\"" || exit 1
review_diff || exit 1
cfg -t || exit 1
kill -USR1 "$lab_pid" || exit 1

The helper makes a precise edit in the temporary source and checks the comparison. In the diff, an exit status of one means the files differ, which is expected after this edit. The signal requests a graceful restart from the private Apache parent. It does not certify that the candidate is active. Give the new generation a brief opportunity to take new connections before collecting your observations. If a probe made immediately afterward still serves the first gallery, use a short bounded retry and inspect the private server error log. Do not change a second variable while waiting for the first change to become observable.

test -f "$ap_lab/second/works/gallery.html" || exit 1
probe portfolio.test /works/gallery.html
probe library.test /
tail -n 6 "$ap_lab/logs/portfolio-error.log"
tail -n 4 "$ap_lab/logs/portfolio-access.log"

When the new mapping has reached the listener, the gallery should return 403. The requested file is present, and the previous syntax test was valid. The error and access logs can point to the path under the second directory. In this fixture, the reason is the explicit wider denial combined with a grant that still applies only to the old tree. The library still serves its independent marker. These results distinguish a scoped failure at the new stage of the portfolio's route from a restart failure affecting the listener as a whole. They also give you a baseline for the next correction.

Now update the directory scope that belongs to the same virtual host so it describes the new physical destination. It is the same small public policy, including the rule for the reserved file, and moves within the same site. Do not put a broad grant on the parent folder and do not change the library block. Before activating, read the complete diff against the initial backup. It should show the mapping and its corresponding Directory line. The protected filename remains part of that changed scope. Test, signal the isolated parent, and allow the new generation to accept fresh connections.

change_line "    <Directory \"$ap_lab/first\">" "    <Directory \"$ap_lab/second\">" || exit 1
review_diff || exit 1
cfg -t || exit 1
kill -USR1 "$lab_pid" || exit 1

Capture the intended final state using the same path inputs as before. The text identifies the release, so a 200 from the wrong version cannot silently pass. The negative file control matters as much as a successful home. Verify the exact reserved marker file exists on the second path while its URL still returns 403. If it becomes readable, stop and correct the authorization change in the lab. A changed root followed by a widened grant could otherwise fix one visible problem while introducing a new access problem. A library marker check confirms the specific virtual host benefited.

probe portfolio.test /
probe portfolio.test /works/gallery.html
probe portfolio.test /works/staff.txt
probe portfolio.test /works/missing.html
probe library.test /
tail -n 6 "$ap_lab/logs/portfolio-access.log"

The home and gallery should have the second-release markers with HTTP 200. The reserved path should still be 403; the absent path should still be 404. The successful gallery lookup in the private log should name the new physical file. When looking at a computed filename for a failed response, remember that the field records the candidate used in request processing. It is not proof that the file was opened or that its contents were delivered. A suitable marker from curl and a matching access log are stronger evidence together.

Make rollback equally specific. Copy the exact saved file back into its original place and compare bytes before parsing. Confirm the service is still your private child. Request the old gallery, homepage and reserved policy again after activation. Do not remove the previous tree before testing; it is the content part of the restore. The library should still answer consistently. In an actual rollout, reversal might be achieved through version control or a deployed artifact. The same principle applies, to restore the complete state and prove it using the same observable inputs.

cp -p -- "$saved_file" "$site_file" || exit 1
cmp "$saved_file" "$site_file" || exit 1
cfg -t || exit 1
kill -USR1 "$lab_pid" || exit 1
probe portfolio.test /
probe portfolio.test /works/gallery.html
probe portfolio.test /works/staff.txt
probe library.test /
apache_root_cleanup
trap - EXIT
test ! -e "$ap_lab" && printf 'DocumentRoot lab removed.\n'

The verified rollback markers should be portfolio first home, portfolio first gallery, intended denial and library control. If an early request still uses the previous generation, wait briefly and repeat before removing the private files. Save your notes and then run the last three cleanup lines. Teardown removes the practice instance and its generated config, releases and logs. The final condition checks that the generated folder is absent. If you used a disposable cloud instance for practice, retire that resource separately using the account's normal cleanup procedure when you are done with it.

Use the error message to tell denial from missing content

When a request fails after the same change on an approved training server, start with the probe. Write down the hostname, scheme, endpoint, route and status. A bare server address can select a different virtual host. A public edge and an origin instance can return different responses to superficially similar requests. Keep the destination fixed and send the expected authority for the origin test. Locate its log in the time window of your request. If the record appears on another virtual host or never reaches the site you changed, correct the test target before making a filesystem change.

If the gallery exists and the error message says access was denied by the server configuration, inspect applicable authorization. Look for a broad denial, a name mismatch in a Directory rule, a reserved file that correctly should be denied, or a later URL-scoped authorization directive. Access based on a filename does not move merely because the public root moved if the enclosing Directory container still points at the old tree. Likewise, a URL rule may stay in effect even after a remap. A working homepage and a forbidden gallery can implicate a narrower section. A forbidden homepage and every file under a new path can implicate a shared ancestor or policy.

If the failure cites operating-system access rather than the Apache grant, check traversal and read access under the actual worker identity. Changing permissions as root can briefly make a probe succeed while widening access to other files. Establish which exact object was refused. Use the appropriate read-only path and policy inspection before narrowing any fix. A site directory moved from another location can arrive with different access metadata from files created directly under the target path. An unlabeled or improperly labelled directory under enforcing policy can still fail when the setting appears to grant access. Verify against the platform's policy documentation and expected existing working paths.

If the gallery's URL gives 404, take the computed path seriously. Confirm that the release really has the intended case and parent directory, because a workstation's filesystem can be less strict about case than the Linux target. If the site has a local error template, compare both the returned status and body. Don't assume a prettified error page was the gallery the user requested. If the route is handled by an alias, application or rewrite, draw the before-and-after path selected by that rule too. Changing DocumentRoot fixes only requests that rely on that mapping. An unchanged alias can be a control by design.

If only the homepage is forbidden, compare a direct file on the same site. A working direct file shifts attention to the directory's index candidates and listing policy. If all tested new files fail, the common root or access policy deserves a closer look. This pattern-based diagnosis is faster than starting by resetting permissions across an entire site. Keep the small verified backup close at hand. If the approved release criteria fail and the training workflow calls for immediate restoration, use the already prepared rollback and then diagnose offline.

Adapt the lab to an approved release workflow

The fixture uses a named virtual host with its own included file. On a real package, the source could be a linked site file on Ubuntu or an included file on a system using an httpd convention. The operator's normal service commands differ as well. Verify which unit and parsed host are in scope. If the production answer arrives through a container or other managed routing layer, the file inside Apache may be generated from a repository, a mount or a pipeline parameter. Follow that relationship so your approved change can be reviewed and remains present after a redeployment. The question is always which instruction controls the known listener and named site, not which package path is easiest to type.

Suppose a first release used a site directory under an existing globally allowed public parent, and a second release belongs to a dedicated location outside it. In the first case an explicit local allowance may not have been necessary. Moving the mapping does not carry any inherited exception over from the old parent. The reviewer should inspect the effective rules for both filesystem locations, then give the desired path the same intended public policy in a narrow scope. Carry over any restrictions that belonged to releases, including rules for specific filenames. An inherited grant that happens to make the second path reachable should be scrutinized too, particularly if the directory contains anything intended for another site.

For another case, consider an application that used per-directory override files. If a release adds one inside the new document directory, its settings can enter request processing only when the main policy allows the relevant categories or directives. A test of central files does not execute all possible path-specific access and routing checks. Identify which rules the application actually needs and which can remain in managed configuration. Avoid broadening the override policy for the whole server as a convenience. The standalone fixture keeps overrides off and uses only synthetic files so the authorization change can be traced entirely in the included site file.

Be precise about what a rollback might need. A plain release of static HTML and images can often be recovered by restoring both the mapping and access scopes while preserving their old files. A site with a separate application API, an upload service or data migrations may need independent compatibility checks. A new theme can send a request that older application code cannot handle. Similarly, an old static shell can fail because its assets were removed from a public delivery layer. Inventory those dependencies when present, and agree on the smallest complete restore procedure before activation. In the lab the previous content, listener and library remain available specifically to make the rollback reason visible.

There are two audiences for the release evidence. The maintainer needs to know what the parent process accepted and whether shared neighbors are working. The visitor needs the correct bytes from the ordinary public address. A process can still be draining requests that started before a graceful change while new requests reach initialized workers. Make fresh requests against the intended endpoint, and use a reasonable bounded wait for the expected version marker. If only one old request completes after the cutover, find out whether it began before activation. If a series of fresh requests keeps returning the previous marker, inspect actual service state, the loaded candidate and any external caching or backend selection.

Protect the rollback point during that observation window. If a file deployment and a config deployment use different tools, identify both versions explicitly and record who owns each. An old root path may point through a link or mounted release directory. The path text being the same in a backup does not by itself prove the old bytes are still reachable. Check a direct gallery marker from the saved content tree and then prove it again through the restored HTTP rule. Keep your verification at that small targeted scope so a service status check cannot mask a missing asset or a change to an independent virtual host.

If you support more than one training workstation, verify the cause on the intended target platform. A folder or filename with uppercase letters can be distinct from a similar lowercase name on many Linux filesystems. A local build on a workstation can accidentally conceal that distinction. Check the server's actual path spelling and the links written into the built HTML. A new build can legitimately place assets under a content-hashed name; in that case the right review checks the links produced with that release and whether the referenced files are present. Treat build paths, host paths and public URLs as distinct names that occasionally look alike.

Record the four evidence states

In your lab report use four rows for initial, mapping-only, complete and restored. Fill in the parsed root, path named by the public Directory rule, machine and port of the probe, direct gallery status and body, reserved file status where observed, and independent library result. Write the difference between a content failure and an intended denied request in one sentence. The mapping-only row should explain that the selected file existed but was denied by the explicitly staged policy. The complete row should explain why the successful gallery and denied fixture together provide stronger evidence than either alone.

Include one precise time in the record for each graceful activation and another for the first matching response. The two are separate events. A future operator can compare those times with the site and parent-process logs to see whether a stale response occurred before the new generation took traffic. Record which requests were brand new so connection reuse does not blur that comparison.

For a separate tabletop test, plan a move where the first content folder and second content folder both sit below a common public parent. Which conclusion from the fixture no longer necessarily holds? A missing local grant may not create a 403 when both folders inherit a permitted policy. Identify a different test to confirm the scoped rules are correct. You can compare ordinary file and reserved path probes and explicitly inspect the effective configuration. Good diagnosis carries forward the distinction between mapping and authorization without assuming the particular failure must appear on every host.

As a practical follow-up on a new lab run, add a second public file only to the new release, under the existing works subdirectory. If you choose the filename brochure.txt, the expected results are 404 initially, 403 after moving the mapping without the grant, 200 after the complete move, and 404 again after rollback. Verify only in this temporary fixture because the middle stage is intentionally disruptive. Compare the result to the staff-control status. Both files can exist at the new path while the same code initially arrives for broadly denied content. After the complete move, those probes separate the allowed new public file from the reserved one. The exact sequence turns a diagnosis into something the student can demonstrate.

Interview questions, quiz and revision cards

What is the difference between DocumentRoot and a matching Directory section?

DocumentRoot provides the base for normal static-file mapping. A Directory section supplies options and policy for a particular folder on disk. If mapping moves, a rule tied to the old directory still refers to that old path. Check inherited policies and move only the grants and restrictions that should apply to the new public content.

Does changing DocumentRoot alone always cause a 403?

No. It caused a 403 in this exercise because the global configuration denied the filesystem and allowed only the old public path. On a server where another rule already permits the new path, the site could be reachable with inherited settings. Identify the effective policy and test the desired access and denial cases before accepting the new release.

Why did the candidate pass a syntax check while the gallery was forbidden?

Both the mapping and the access rules were valid instructions. Taken together, those instructions denied access to the selected new directory. The parse did not attempt your desired visitor workflow. A targeted request and the error log showed the runtime policy outcome.

What is the first comparison if a website by domain and by bare IP differ?

Check which virtual hosts those two authority values select on the same listener. A raw address can reach a first eligible fallback. Retest the intended name while controlling its destination, then read the response marker and the correct access log.

How can you check that the move preserved a restricted file rule?

Make the fixture file exist in both releases, and check the intended denial before and after the move. A newly deployed homepage that succeeds cannot demonstrate a separate restricted path is still protected. Use harmless test content rather than an actual sensitive file.

Quick quiz

  1. The lab's portfolio syntax passes, its gallery exists in release two, and the log says client denied by server configuration. What should you check first?

    1. The matching Directory scope and authorization under the selected path
    2. Whether the browser needs a different CSS file
    3. Whether the port should change
    Check the first answer

    A. The named request reached Apache and resolved the candidate, but the applicable policy denied it. In the fixture, re-scope the existing narrow grant and its restrictions.

  2. Which check shows that only the intended site moved?

    1. Any HTTP 200 from the raw address
    2. New home and gallery markers from portfolio, and the unchanged library marker on the same listener
    3. One successful syntax check with no probes
    Check the second answer

    B. It verifies the change and an independent site using meaningful bodies with fixed hostname and endpoint inputs.

  3. What do you need for a verified restore of the static releases in this exercise?

    1. A new broad grant on the entire filesystem
    2. Only a copy of the old homepage from a browser cache
    3. The saved mapping and matching policy, available original files, and repeatable HTTP checks
    Check the third answer

    C. The config selects the old content and its intended access rules. The observed home, gallery, reserved result and library body demonstrate the recovery.

Mapping and permission

DocumentRoot guides the lookup. Directory contributes filesystem policy. A syntactically valid pairing can still deny a request.

Check both directions

A new public marker must be readable, and an existing reserved test file must remain denied. Neither probe substitutes for the other.

Keep the site selected

Use the correct authority on the known listener. A raw address can choose the first virtual host and make a successful response misleading.

Restore the complete release

Recover the scoped settings and keep their target content available. Verify the original markers and independently test the neighboring site.

Primary references