Mastering Nginx

(Ron) #1

A Configuration Guide


[ 22 ]

NGINX global configuration parameters


The global section is used to configure the parameters that affect the entire server,


and is an exception to the format shown in the preceding section. The global section


may include configuration directives, such as user and worker_processes, as well
as sections, such as events. There are no open and closing braces ({}) surrounding


the global section.


The most important configuration directives in the global context are shown in the


following table. These will be the ones that you will be dealing with for the most part.


Table: Global configuration directives

Directive Explanation
user The user and group under which the worker
processes run is configured using this
parameter. If the group is omitted, a group
name equal to that of the user is used.
worker_processes This is the number of worker processes
that will be started. These will handle all
connections made by the clients. Choosing
the right number depends on the server
environment, the disk subsystem, and the
network infrastructure. A good rule of thumb
is to set this equal to the number of processor
cores for CPU-bound loads and to multiply
this number by 1.5 to 2 for I/O bound loads.
error_log error_log is where all errors are written.
If no other error_log is given in a separate
context, this log file will be used for all errors,
globally. A second parameter to this directive
indicates the level at which (debug, info,
notice, warn, error, crit, alert, and
emerg) errors are written to the log. Note
that debug-level errors are only available
if the --with-debug configuration switch is
given at compilation time.
pid This is the file where the process ID of the
main process is written, overwriting the
compiled-in default.
Free download pdf