Nginx CLI options: inspect and test configuration
Choose a command for the job
The Nginx executable can display information, validate a configuration, start a server or send a control request. These are different operations. Begin with the information commands, which exit without starting a server. A lowercase flag and its uppercase counterpart may do different things.
Help lists available options. The short version command reports the release, while the verbose version command adds compiler and build configuration details. On the authoring machine the installed release is 1.26.3; your output will vary. Build flags alone do not establish which dynamic modules a running instance loads.
Select a lab configuration
These examples use the Chapter 4 disposable lab, not a system Nginx service. The optional commands require a reviewed patched Linux Nginx binary, unprivileged user, a private lab directory and an available loopback port. Expected outputs are predictions, not recorded executions. Set LAB to the absolute path of your own copied Chapter 4 directory, as described in its README. A prefix establishes the base for relevant relative runtime paths; -c explicitly selects the configuration file. Absolute paths in a configuration are not redirected by -p.
nginx -e stderr -p "$LAB/" -c "$LAB/nginx.conf" -tA successful test means Nginx could parse the configuration and perform its configuration-time file checks. The command exits; it does not start the service or prove that a listener can bind, a backend can answer, or a request reaches the intended handler. Treat a nonzero exit as a reason to stop the change and investigate.
nginx -e stderr -p "$LAB/" -c "$LAB/nginx.conf" -t -qnginx -e stderr -p "$LAB/" -c "$LAB/nginx.conf" -TThe quiet flag suppresses routine test messages, not errors. The uppercase test flag also writes the configuration files, including included files, to standard output. It is not a report of the live configuration in worker memory.
Do not run a dump against an unknown service or paste production output into a ticket. Configuration can contain credentials, internal hostnames and private routing rules. A test may open files and load configured modules, so use only reviewed fixtures.
Other options and version differences
nginx -e stderr -p "$LAB/" -c "$LAB/nginx.conf" -g 'worker_shutdown_timeout 5s;' -tThe -g argument supplies main-context directives; do not use it to repeat an existing single-value directive. The example uses a setting deliberately absent from the lab configuration. The -e stderr option selects standard error for early diagnostics; an explicit configuration error log may still receive messages. The -s option controls the master and is covered in the lifecycle lesson. -? is another help spelling (quote it in a shell to prevent wildcard expansion). Current upstream documentation also describes -l for the control REST API from 1.31.5 in Open Source; this is absent from the observed 1.26.3 help. Do not enable a control endpoint for this beginner lab.
Practice: choose the least intrusive option
Choose a command for identifying a binary version, inspecting build flags and checking a proposed file without starting the server. Explain why a successful test is weaker evidence than a verified HTTP response. Next, learn how the running master and workers differ.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
CLI options and validation
Check the concepts taught in this lesson.
Which command lists compile-time options?
A proposed file is valid. Which operation checks it without starting the service?
Why avoid posting output from -T?
What does -q change when used with -t?
What should you conclude from a successful configuration test?