Chapter 6: Web Servers — Nginx and Apache
6.8 Everyday management commands
Friends, once the web server is installed, the daily work is the same: test, reload, look at the logs. This table will be used every day on the Amul-style dairy server – once it is in your hands, troubleshooting becomes fast.
मित्रांनो, वेब सर्व्हर इन्स्टॉल झाला की रोज हेच काम: टेस्ट, reload, लॉग्स बघणं. हा टेबल Amul-स्टाइल डेअरीच्या सर्व्हरवर रोज वापरला जाईल – एकदा हातात बसला की ट्रबलशूटिंग फास्ट होतं.
दोस्तों, वेब सर्वर इंस्टॉल हो गया तो रोज़ यही काम: टेस्ट, reload, लॉग्स देखना. ये टेबल Amul-स्टाइल डेयरी के सर्वर पर रोज़ इस्तेमाल होगा – एक बार हाथ में बैठ गया तो ट्रबलशूटिंग फ़ास्ट हो जाती है.
| Task | Nginx | Apache (AL2023/CentOS) | Apache (Ubuntu) |
|---|---|---|---|
| Test config | sudo nginx -t |
sudo apachectl configtest |
sudo apache2ctl configtest |
| Reload (when supported) | sudo systemctl reload nginx.service |
sudo systemctl reload httpd.service |
sudo systemctl reload apache2.service |
| Restart | sudo systemctl restart nginx.service |
sudo systemctl restart httpd.service |
sudo systemctl restart apache2.service |
| Common error log | sudo tail -n 20 /var/log/nginx/error.log |
sudo tail -n 20 /var/log/httpd/error_log |
sudo tail -n 20 /var/log/apache2/error.log |
| Common access log | /var/log/nginx/access.log |
/var/log/httpd/access_log |
/var/log/apache2/access.log |
| Version | nginx -v |
httpd -v |
apache2 -v |
| Build options or modules | nginx -V (build options) |
apachectl -M (modules) |
apache2ctl -M (modules) |
Always test before reload
Test the same configuration selected by the running service. For the standard systemd Nginx unit, a passing sudo nginx -t can precede an authorized sudo systemctl reload nginx.service. Check the named route afterward. A syntax check cannot confirm that a valid website rule serves the intended content.
Ravindra Bagale's Tip
Check the diagnostic printed by the configuration test. It may identify a file and line where parsing failed. For a running service, inspect its configured error log and the unit journal. Common destinations include /var/log/nginx/error.log and /var/log/httpd/error_log.
Ravindra Bagale's Tip – मराठी
कॉन्फिगरेशन तपासणीचा संदेश आधी वाचा. त्यात parsing अडलेली फाइल आणि ओळ दिसू शकते. सुरू असलेल्या सेवेसाठी तिचा कॉन्फिगर केलेला error log आणि unit journal तपासा.
Ravindra Bagale's Tip – हिंदी
पहले कॉन्फ़िगरेशन जाँच का संदेश पढ़ें. उसमें parsing रुकने वाली फ़ाइल और पंक्ति मिल सकती है. चालू सेवा के लिए उसका निर्धारित error log और unit journal देखें.
Lab
Chala, use the private exercise below. Test an invalid candidate in a separate file, confirm the current request still returns its original body, then apply a valid candidate and check both routes.
The daily routine, explained step by step
- Review the intended files and preserve the current version.
- Test the selected candidate with the installed server.
- Apply through its supported service mechanism after validation.
- Check the named request and an unchanged comparison, then read the corresponding logs.
Checking an application behind the web server
A process manager can show that the backend is running. Check the backend's actual address, port or socket and its expected request protocol. For an HTTP service, test an authorized method and path with the expected result. An app can be online while one route returns an error. A FastCGI service such as PHP-FPM requires an appropriate FastCGI route and logs rather than an ordinary HTTP request to the FastCGI socket.
Recap
Record the before response, review and test the candidate, apply through the intended service, then compare the named request with the expected result.
Change a running site with a repeatable check
Think of the sample dairy from the earlier lessons. Its website shows collection information for each outlet. The team has approved a new link to Saturday's timetable while customers are already using the site. The engineer needs to change the link and verify it went live without guessing which server returned the response. If the candidate fails a configuration check, customers should continue to receive the current route while the engineer fixes the candidate. A service command can help make the change, but the business goal is what gives that command meaning.
Start by describing one old response and one expected new response. Perhaps a visit to the route status page currently says Release A and should say Release B after the route configuration is applied. Write down the site name, port, request method, path and expected marker. Also choose a small unchanged comparison, such as a page that should still be reachable. Both requests can then be repeated immediately before and after the change. If one response is unexpected, the team already has a concrete reason to stop and inspect the change.
A service is a program running in the background with a defined way to start and stop it. A web service often has several process roles. Nginx has a master that supervises workers, and workers service requests. Apache has a parent process and a request-handling arrangement determined by the installed processing module. A configuration file on disk and the configuration actually in use by those processes are separate. Editing a file can succeed while the live response remains the same. You need a controlled application step for a configuration change, followed by a request that observes its effect.
The management commands in the short table above are a reference for the named packaged installations. First confirm the service unit, its configuration selection and your authorized maintenance process. A privately started practice instance has its own controls, and a container or other supervisor may use different commands. Calling the system service manager blindly can affect an existing site when you intended to reach only your practice process. Conversely, starting an extra executable by hand can create a second server that tries to bind the same address and port. Identify the owner and the intended control surface before invoking a change.
Read the service state before choosing a command
On a Linux installation managed by systemd, a unit is an object the manager controls. A service unit describes how an executable is managed. A unit named nginx.service usually describes the packaged Nginx service. A package may instead install another unit or a customized installation may use distinct named instances. The same distinction explains why Apache usually uses httpd.service on Amazon Linux 2023 and CentOS Stream 9, and apache2.service on Ubuntu. The web server's name in documentation and its local unit name are different pieces of information.
Starting a unit asks the manager to activate it now. Stopping asks it to deactivate now. Enabling a unit usually creates the installation links that allow a target or another configured unit to bring it in automatically, often at boot. You can enable a stopped service or run a disabled service. For example, a teacher may start a lab temporarily and deliberately leave it disabled so a future boot does not automatically start that unit. An enabled unit could be inactive because its start has not happened or a prior attempt failed. A separate manual process can also exist regardless of the unit's state.
Use systemctl status nginx.service --no-pager to inspect a known name in an authorized systemd shell. It can show the load state, activity, the main process and recent log lines. systemctl is-active nginx.service asks a narrower question suitable for a simple check. systemctl is-enabled nginx.service examines the installation state, and can return states such as static or masked in addition to enabled or disabled. Treat those values as information about the manager rather than a health guarantee. A green manager status cannot tell you whether the designated outlet page on the designated hostname contains the correct link.
Use systemctl cat nginx.service to inspect the unit on disk and its drop-ins where you have access. A drop-in is a snippet that changes selected unit instructions without editing the package's original unit. In an incident, inspect instructions such as ExecStart or ExecReload if present. They may reveal a selected entry configuration or wrapper. systemctl show nginx.service -p MainPID -p FragmentPath -p UnitFileState asks the manager for individual properties. The unit's on-disk text and what the manager loaded can differ after an unapplied unit edit, so write down the distinction when debugging a service definition.
If a deliberate change affects the unit definition itself, systemctl daemon-reload asks systemd to reload unit definitions. It is a manager operation. If a change affects the web server's configuration, systemctl reload nginx.service requests that this unit reload its service-specific configuration, if the unit supports reload. The first operation does not reload an Nginx site's rules. The second does not reread all systemd unit files. If the unit environment is changed, the approved application plan may need a service restart after the manager rereads the definition. The instructions depend on what changed and how the service uses that input.
A restart is typically a stop and start of the managed service. It can interrupt existing work, which matters even if the website returns a page immediately afterward. A configuration reload is intended to apply suitable changes without taking the listening service deliberately offline. It still carries risk if the new configuration is semantically wrong, and an Apache graceful restart uses its own server-specific behavior. Ask what the unit actually does under reload. If it provides no supported reload action, do not silently replace it with a restart. Service interruption and coordination with other operators are separate decisions.
Protect the current configuration and review the candidate
Save a known starting point before changing the configured route. Identify the main configuration, the particular included file and any file or link that will also change. A backup of the main file alone cannot restore a changed file included from another folder. Preserve ownership and mode where they matter, record the active version, and keep backups outside active include globs. Treat copies as private if the configuration contains internal addresses, credential material or certificate paths. A helpful note identifies the version, time, location and a person or process authorized to restore it.
Suppose the root configuration includes every file in a directory named conf.d that ends with .conf. Saving a backup there with a name such as site-old.conf makes it look preserved while the parser may still read it. Your next test might find an unexpected duplicate listener or name. Use a separate controlled location. When reviewing a colleague's change, read the comparison and make sure you can name every file that will differ. If several unrelated edits are present, decide which change should be applied and review the others separately with the responsible owners.
A candidate is the proposed configuration before apply. To compare two ordinary non-sensitive files in a practice directory, use diff -u old.conf candidate.conf. A leading minus marks a line present on the old side and a leading plus marks a line present on the new side. A comparison reports a difference with exit status 1, while other error statuses can indicate the comparison itself failed. An expected difference is evidence, so a shell script that treats every nonzero return as the same failure needs to account for that behavior. Read the changed section and its enclosing context before moving to a server-specific test.
The candidate test should include all dependent files and conditions of the intended installation. An alternate configuration path can alter where relative includes are resolved. A different binary may have different module support. An invocation run without the usual wrapper on Apache can omit the environment or options that the unit supplies. A check under a privileged user may also open a path that ordinary request workers cannot use at runtime. Use the service's documented checking command and compare it to the actual invocation. A passing test is one piece of the evidence and a file or route check is another.
Little changes can have broad effects. Moving a directive from one site into a shared HTTP section might change several sites. Changing a default host can affect traffic with a different or unknown name. A directory root can return a valid but unintended file. A proxy target can be syntactically acceptable while the app is absent. Before applying a change, state what should happen to one affected request and one request that should be unaffected. Briefly sketch who else shares the config or port. This is especially helpful for a host serving multiple websites.
Interpret config checks and reloads separately
Nginx's -t checks configuration syntax and tries to open relevant referenced files as part of its validation. Read both the reported path and diagnostic. For instance, an invalid value can point straight to its line, while a forgotten delimiter may make the parser report the next line where it can no longer understand the directive. Fix the cause at the candidate, run the same check again, and stop on a failure. Do not use a live file as a typing practice sheet. The private lab below uses a separate candidate specifically so a malformed example never replaces its working text.
In many Bash commands, the && operator runs the right-hand part only when the left-hand command exits successfully. It makes a useful guard when the left action tests precisely the configuration the right action will apply. It cannot know whether the catch-all points to the intended site or the wrong backend was written down. It cannot guarantee that a second writer will leave the file unchanged between the check and reload. On a managed deployment, serialize authorized edits through the same release process and observe the response after apply. A skipped reload is the desired result when the candidate validation fails.
What does reload do in Nginx? It signals the master to reread its configuration. The master tests and attempts to apply the new settings, including starting new workers and opening needed resources. If it cannot apply them, it can continue using the old configuration. When the change is accepted, old workers normally finish existing work while new workers take new requests. The command that sends the signal can finish before the response from the new routing is observed. A result in your terminal saying a signal was sent is a reason to verify the route, particularly when old and new workers briefly overlap.
Apache operators often use an apachectl configtest or the distribution's apache2ctl configtest wrapper. A successful check commonly prints Syntax OK, possibly with warnings that still deserve attention. An Apache graceful operation can reread configuration while allowing workers to finish current requests. The exact behavior is important when log rotation or long-lived requests are involved. The project's control program can start the server during certain actions if it is not already running, so confirm the intended unit and current state before choosing the packaged reload or control command. Do not treat the word graceful as a guarantee for every possible update.
Consider a syntax test that reports success and a reload command that exits cleanly, followed by the old response marker. The application may be delayed, the request may be reaching a different endpoint, or the actual changed setting may be irrelevant to that URI. Use a new request with the correct hostname and path. Check the selected config path and private or unit logs at the time of apply. If working behind a proxy or load balancer, compare an authorized backend request with the request through the frontend. A browser cache can hold old content, but that is a hypothesis to test rather than the automatic explanation for every stale page.
Check a request users actually care about
A short HTTP probe is useful because it asks the web server directly and gives evidence you can save. A request using curl -I sends HEAD. It normally displays response headers without a body. Use it to check the visible status, a redirect target, or headers on an endpoint where HEAD behaves as expected. Use a GET when the important evidence is text in the body, a supporting file or a route implemented only for GET. The site loading over loopback while you are logged in provides local evidence. It does not establish public DNS, network access through a firewall or the chosen certificate for a real HTTPS host.
For a named site on an authorized machine, choose an explicit URL and a bounded request time. A curl command can use --resolve to map a specific hostname and port to an authorized test address without changing DNS, while keeping the URL hostname used for HTTP and HTTPS checks. In plain HTTP you can also supply an explicit Host header while connecting to loopback, as in the configuration lesson. For HTTPS with normal names and certificates, keep hostname verification enabled and use the intended name through the actual test path. The lab uses plain local HTTP, so its result does not test a certificate.
By default a 404 response can still leave curl with a successful transport exit, because reaching the server and obtaining an HTTP reply worked. With --fail, curl reports HTTP error status as a command failure for ordinary HTTP errors, which is useful when success is required. During a planned negative test, capture the status you expect without accidentally aborting an entire script because a missing-file response is correct. Print the status and compare the body marker separately where both matter. The evidence for a plain static page is different from an application route that returns a JSON result or a redirect.
Suppose the first GET shows a 301 for the changed route and includes a new Location header. If the desired behavior is a redirect, that observation is useful but still only one step. Make an authorized request to the intended destination and check the content there or follow the chain if it is permitted. If the route should return a local page, the 301 marks a route mismatch, even if following it yields a page somewhere. Record the first response before automatically following redirects so you can tell which rule produced which answer. A simple build-up avoids concluding a redirect worked merely because you landed on an unrelated valid homepage.
For a user-facing service, local and external checks answer complementary questions. A local check can isolate the intended process from cloud DNS or routing issues. A verified external request through the normal path includes the name service, network ingress and TLS, plus any proxy, cache or load balancer. You still need the right path and marker. If the app sits behind the web server, its own local diagnostic endpoint answers a different question from the route that proxied it. Keep those observations in a short table in the change record. A colleague should see which layer works without guessing which URL you tried.
Read the log that answers the current question
An access log accompanies web requests. It can show the requested method and path, response status, time and other fields selected by the configuration. An error log records server diagnostics, such as an inability to open a file, a configuration problem or an upstream connection failure. The systemd journal can capture manager events and process output for the unit. Applications upstream can write their own separate logs. If a status command tells you a process restarted, look in the unit journal for the startup event. If a route returned 404, find the access entry for the test and look for a corresponding message in the error log if one was configured.
Search around a known time and a distinctive request. Try journalctl -u nginx.service -n 20 --no-pager for a recent bounded sample, if you have permission to read the journal. With a known incident time, an appropriate --since value helps focus that search. For a file log, tail -n 20 prints the recent lines already present, whereas tail -f continues watching until stopped. A log can be rotated or assigned a per-site path. Check the configured path before assuming a default file has every entry. Avoid copying whole logs into a public conversation because paths, query values and internal names may disclose details unrelated to the question.
An access log may show a timestamp in the server's time zone, while an incident chat may be written in local time. Include the offset or convert to one known time basis before correlating observations. If a colleague made the request from a shared network, an address alone might describe several users. A distinctive harmless path or marker from your diagnostic request gives a better correlation than relying on source IP alone. A missing log entry can indicate a wrong site, disabled logging, use of another log destination, delayed output or a request that never reached the server. It is a clue to narrow rather than an automatic verdict.
Version information is useful for matching installed options. nginx -v prints the executable version. nginx -V adds build information such as configure arguments. That does not by itself enumerate modules loaded by a particular running configuration. Apache's -M via its package-appropriate wrapper lists loaded static and shared modules for that configuration check. If an instruction is suddenly unknown, verify the selected binary, module and config context before installing anything. A classroom sample may target a different package or version from the one running today.
If a change fails verification after apply, pause the release and decide whether to restore the known good version through the approved procedure. That is usually a deliberate change, not a restart reflex. Identify which configuration and supporting contents must be restored. Validate the restored candidate in the same environment, apply it through the owner, check the named response and compare the logs. If an app or data change also happened, a web server config restore might be insufficient. Document what you proved and hand the remaining question to the correct owner.
Lab that tests a bad candidate without changing the running route
Use a disposable Linux learning machine with Bash, Python 3, curl and Nginx supporting the separate bootstrap log option. The exercise starts a private instance as your ordinary user. It listens only on loopback and uses a freshly generated directory. Each block builds on variables in the same terminal. If the first block cannot prepare a directory and port, follow the paper practice after the lab. The release markers below are fixed responses for the exercise, like a sign that tells you which site configuration currently handles requests.
unset ops_lab ops_port ops_url
if [ "$(id -u)" -ne 0 ] && command -v python3 > /dev/null &&
command -v curl > /dev/null && nginx -e stderr -h > /dev/null 2>&1; then
ops_lab=$(mktemp -d "$HOME/nginx-ops.XXXXXXXX") && cd -- "$ops_lab" && pwd
ops_port=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()')
printf 'Practice port %s\n' "$ops_port"
fi
The socket probe chooses an available local port. There is a small interval between closing the probe and starting Nginx. If the private instance reports that the port is already in use, leave the listener that holds it alone and use your logs to confirm the failed start. A new exercise can choose a different port after you account for the scratch files. In the ordinary case, the instance starts and you can observe its PID in a file inside the directory printed above.
if [ -n "$ops_lab" ] && [ -n "$ops_port" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ]; then
cat > ./nginx.conf <<EOF
worker_processes 1;
pid "$ops_lab/nginx.pid";
error_log "$ops_lab/error.log" notice;
events { worker_connections 32; }
http {
access_log "$ops_lab/access.log";
client_body_temp_path "$ops_lab/body";
proxy_temp_path "$ops_lab/proxy";
fastcgi_temp_path "$ops_lab/fastcgi";
uwsgi_temp_path "$ops_lab/uwsgi";
scgi_temp_path "$ops_lab/scgi";
default_type text/plain;
server {
listen 127.0.0.1:$ops_port;
server_name localhost;
location = /route { return 200 "Release A"; }
location = /baseline { return 200 "Reference unchanged"; }
}
}
EOF
ops_nginx=(nginx -p "$ops_lab/" -e "$ops_lab/bootstrap.log")
if [ ! -s ./nginx.pid ] && "${ops_nginx[@]}" -c "$ops_lab/nginx.conf" -t &&
"${ops_nginx[@]}" -c "$ops_lab/nginx.conf"; then
for ops_attempt in {1..20}; do
[ -s ./nginx.pid ] && break
sleep 0.1
done
if [ -s ./nginx.pid ]; then
ops_url="http://127.0.0.1:$ops_port"
curl --noproxy 127.0.0.1 -fsS --max-time 5 -w '\nHTTP %{http_code}\n' "$ops_url/route"
curl --noproxy 127.0.0.1 -fsS --max-time 5 -w '\nHTTP %{http_code}\n' "$ops_url/baseline"
fi
fi
fi
The starting configuration defines two exact path locations, each ending immediately with a response marker. You should see 200 with Release A from the first URL and 200 with Reference unchanged from the second. A successful configuration test by itself would not prove a worker had started or that those paths selected the intended response. The new GETs and the private PID file together establish a baseline that you can compare against the next observations.
Now make a separate backup and a deliberately invalid candidate. The substitution first makes an invalid value for the worker count, leaving the running config filename alone. A rejected check is the expected successful teaching outcome here. Read the filename and error, then read the currently served marker. In an actual change, the equivalent step records a failed preflight and returns the candidate to review. The running deployment stays at the previous release until a valid candidate is ready.
if [ -n "$ops_url" ] && [ -n "$ops_lab" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ] && [ -s ./nginx.pid ] &&
cp -p -- ./nginx.conf ./original.conf; then
sed 's/worker_processes 1;/worker_processes invalid;/' ./original.conf > ./candidate.conf
if "${ops_nginx[@]}" -c "$ops_lab/candidate.conf" -t; then
printf '%s\n' 'Unexpected success: inspect the candidate and stop here.'
else
printf '%s\n' 'Candidate rejected: keep the running configuration.'
cmp -s ./original.conf ./nginx.conf && printf '%s\n' 'Current file still matches its backup.'
curl --noproxy 127.0.0.1 -fsS --max-time 5 -w '\nHTTP %{http_code}\n' "$ops_url/route"
fi
fi
The diagnostic should mention the candidate and an invalid value for worker_processes. Configuration diagnostics may appear directly in the terminal rather than the error file for the running service. Read the exact path to see which command produced the observation. The comparison reports the working file still matches its backup, and the GET still shows Release A. The guard here is the operator's decision to keep the candidate separate and skip apply, not a claim that any arbitrary invalid activity can be performed against a live configuration.
For the next candidate, start again from the preserved good file and change just the response marker. Review the diff before applying. You should see one deletion and one addition for the route line. Inside the lab you may apply the following block through the same private path and process. It checks the candidate, swaps it into the private main filename, tests that path, then signals the same master. The request loop waits briefly for the worker generation that returns the expected marker.
if [ -n "$ops_url" ] && [ -n "$ops_lab" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ] && [ -s ./nginx.pid ] && [ -f ./original.conf ]; then
sed 's/Release A/Release B/' ./original.conf > ./candidate.conf
diff -u -- ./original.conf ./candidate.conf
fi
if [ -n "$ops_url" ] && [ -n "$ops_lab" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ] && [ -s ./nginx.pid ] &&
"${ops_nginx[@]}" -c "$ops_lab/candidate.conf" -t &&
mv -- ./candidate.conf ./nginx.conf && "${ops_nginx[@]}" -c "$ops_lab/nginx.conf" -t &&
"${ops_nginx[@]}" -c "$ops_lab/nginx.conf" -s reload; then
for ops_attempt in {1..15}; do
ops_body=$(curl --noproxy 127.0.0.1 -fsS --max-time 2 "$ops_url/route") &&
[ "$ops_body" = 'Release B' ] && break
sleep 0.2
done
printf 'Route after reload: %s\n' "$ops_body"
curl --noproxy 127.0.0.1 -fsS --max-time 5 -w '\nHTTP %{http_code}\n' "$ops_url/baseline"
tail -n 6 ./access.log
tail -n 12 ./error.log
fi
You should see Release B and the same Reference unchanged comparison. The response proves the newly configured handler answered. The recent error log commonly reports a reconfiguration and worker activity at the chosen notice level. Exact process numbers and entry wording depend on the installation. If the route never changes, keep the results and check the error log before deciding to restore. Compare the requested filename, process configuration and response with the values recorded at the beginning. Save the specific evidence rather than repeatedly applying a command in the hope that it starts to work.
After taking notes, shut down only the private master using its full invocation. Wait for the private PID to disappear and inspect the expected files before removing them. Use this cleanup after successfully applying the valid candidate, which consumed the candidate path. If you stopped between stages, an extra candidate copy may still be present. Inspect it by name and remove it only inside the identified scratch directory before completing directory cleanup. A remaining private process or unexpected file deserves inspection.
if [ -n "$ops_lab" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ] && [ -s ./nginx.pid ]; then
"${ops_nginx[@]}" -c "$ops_lab/nginx.conf" -s quit
for ops_attempt in {1..30}; do
[ ! -e ./nginx.pid ] && break
sleep 0.1
done
fi
if [ -n "$ops_url" ] && [ -n "$ops_lab" ] &&
[ "$(pwd -P)" = "$(cd -- "$ops_lab" && pwd -P)" ] && [ ! -e ./nginx.pid ]; then
ls -la -- .
rm -i -- ./nginx.conf ./original.conf ./bootstrap.log ./error.log ./access.log &&
rmdir -- ./body ./proxy ./fastcgi ./uwsgi ./scgi &&
cd -- "$HOME" && rmdir -- "$ops_lab"
fi
In the alternative paper exercise, put one card marked current configuration and another marked candidate on your desk. Record both route markers. Write an invalid worker value on the candidate and mark it rejected without moving either card. Now replace the candidate with a one-line marker change, note which file is preserved for rollback and decide what you need to see before announcing success. Swap in the card only after the green check. Add a second healthy route that you expect to remain unchanged. Your completed table should have a line for the rejected candidate, the accepted change and each observed marker.
Make a decision from the evidence
Suppose your lab comparison prints two worker-count changes along with the marker change you intended. You now have evidence that the candidate may have been made from a different version or edited by another person. Stop before the apply action. Identify the source backup, inspect a clean comparison and discuss any additional changes with the owner. A passing parser test would not address that discrepancy. The useful message to a teammate would name the intended single route and the unexpected extra diff, without claiming a process failure that has not occurred.
In a second case, a named service is active and you see 200 from the unchanged route, but the changed route has become 404. That evidence suggests the service and listener still answer one path. Investigate the host and path rules for the failure and see whether a request made directly to the appropriate local address returns the same result. Find the matching request in the access log. If a filesystem route is involved, read any attempted pathname in the error log. You can explain both what remained available and what broke. That supports a scoped correction or restoration while minimizing disturbance to other sites.
A third case occurs when a team adds a proxy rule to send a reporting request to a backend process. The web server parser accepts the rule, the frontend timetable still loads, and the report path returns a gateway error. Check the upstream named by the selected route and compare its protocol, address and port or socket with actual backend evidence. A service manager might show the backend as active even though the expected listener has not appeared. A backend HTTP test can be appropriate where the backend speaks HTTP and you are authorized to access it. PHP-FPM speaks FastCGI, so an HTTP URL at its socket or port is not an equivalent check. In that case use the FastCGI-aware route and service evidence the team documents.
In an incident note, write timestamps and questions as well as outcomes. A useful example reads: the candidate check rejected an invalid worker setting at the named candidate path, the configured route still returned Release A, and the subsequent one-line change returned Release B after a scoped reload. The notes then contain the unchanged comparison marker and the actual log destination. A label such as server fixed gives less information. Another person should know whether the claim refers to syntax, site selection or the response a student needed.
Try writing a restoration plan for the private instance without executing it. Start from the preserved original and name the comparison and test you would repeat. State that you would apply it using the private config path and wait for Release A. Explain what should happen to the reference route and which log would record reconfiguration. Then write a reason not to carry this operation over to a service you do not own. A useful restoration plan can be reviewed before a problem without using a fault as the first opportunity to find the relevant files.
Answer with a command and its evidence
What is the difference between an active and an enabled web service?
Activity is the manager's current state for the unit. Enablement describes links or installation state that can make it start as part of a target or another boot arrangement. I can start a lab service now and leave it disabled for later boots. I can also have an enabled service that failed to start. I would check both states on the correct unit and then use a request to judge the actual site's health. A response from a separately started process is possible even when the packaged unit is inactive.
When would you use daemon-reload?
I would use the systemd manager operation after an authorized edit to a unit file or drop-in where the manager needs to reread the definitions. If I only changed an included Nginx site file, that is a web server configuration change, and the relevant action is the service's supported reload after validation. If a unit edit changes an environment input needed when the process starts, I would check the controlled restart plan. I would name which configuration changed to explain the action I selected.
Can a syntax check prove a proxy route uses the right backend?
The check can accept a validly formed rule without confirming the backend service is available or the target is the service we intend. I would verify the relevant endpoint with the correct host and path through the normal proxy and compare the expected marker or response. If it fails, I would read the frontend error log and check the actual backend listener or socket and supported protocol. That distinguishes a valid instruction from a working request path.
How would you handle a failed candidate in advance of a release?
I would retain the current known good config and keep the rejected candidate separate. I would capture the diagnostic, including the path and directive, and check that the known running route still returns its baseline marker. I would fix only the candidate, inspect the changed lines, and run the correct config check again. Only after a successful review and check would I use the approved apply action. Where possible I would compare the new named response and an unchanged path to the pre-release expectations.
What would you check after systemctl says reload succeeded?
I would repeat the actual path with the correct hostname and HTTP method, check its expected status and marker, and make a small comparison request. I would inspect the appropriate logs at that time if either result differs from expectations. For an Nginx signal-based action, the request can show whether the new worker generation took the intended route. When a proxy or external access is part of the goal, I would also use an authorized request through that normal path.
Why might access, error and service logs each matter in one report?
The access log correlates a request and the returned status. The error log may show what prevented handling that request, such as a file open failure or an upstream connection error. The service journal shows unit control and startup messages when captured there. A useful report ties entries to a time and an endpoint. Then the next engineer can tell whether this was a reload failure, a request mapping problem or an application issue.
Decide before typing the next command
The employee changed only a site include and was told to use the systemd manager's daemon-reload command. Would the web route change on that evidence?
Answer and reasoning
The manager rereads unit definitions through daemon-reload. The site include belongs to the web server. Trace the correct include, run the appropriate configuration test and use the documented service apply, then observe the route. A manager action by itself does not send the new route to Nginx's workers.
The syntax check succeeds but the named test returns 200 with yesterday's timetable. Is the change verified?
Answer and reasoning
No. The status says that request received a successful HTTP response, but the content is still the wrong revision. Check whether the new config was applied, whether your hostname and address selected the intended site, and whether the measured response comes from a proxy or cache. Compare the exact marker, then examine the relevant logs.
A student expects their GET-only application test to succeed with curl's capital I option. What observation might be misleading?
Answer and reasoning
That option makes a HEAD request. An application may handle HEAD differently, and the result contains no body to check the activity marker. Use a GET for the route users actually visit and separately record any header-level verification needed for redirects or caching.
The candidate diff command returned 1 and showed exactly the intended line changed. Does that number mean the file could not be read?
Answer and reasoning
For diff, status 1 normally indicates files differ, and the visible change is expected. Distinguish this outcome from the status for trouble reading or comparing files. Record the intended difference before you turn to the service's configuration validation.
The lab prints an invalid directive value, then a successful GET with Release A. Which action should happen next?
Answer and reasoning
Keep serving the working configuration, retain the failure evidence and rebuild the candidate from the preserved known good text. Review the intended change and pass validation before applying. Release A continuing to work confirms the prior route, while the candidate error explains why the new one did not go live.
Recall the release checks
Running and enabled are separate
Activity answers the current manager state. Enablement tells how a unit is set up to join automatic start targets. A named request answers what the site does.
Two kinds of reload
Daemon-reload is for the manager's unit definitions. A service reload requests that the running application apply eligible service-specific settings. Confirm the selected instance first.
Record a before marker
A recognizable old result, a planned new one and an unchanged comparison let you grade a release by what users see. Capture the status and expected body as needed.
A failed candidate stops apply
Review the diff, validate the correct text and keep backups out of active includes. A rejected candidate belongs in the review path. Preserve the currently working site.
Take one bounded log sample
Start from the time and endpoint. Request evidence, server diagnostics and unit events can point to different layers. Use the actual configured log destinations.
Official references
- systemd service state, unit inspection and reload commands
- systemd journal filtering and output bounds
- Nginx configuration and version options
- Nginx master, reload and worker shutdown behavior
- Apache control wrapper and configtest
- Apache restart and graceful control behavior
- Apache version and loaded module options
- curl request method, hostname mapping, time bounds and failure option
- GNU diff option and exit status reference