Nginx Main Module

这里是控制 Nginx 的基本功能的指令.

指令

daemon

语法: daemon on | off

缺省值: on

daemon  off;

Do not use the "daemon" and "master_process" directives in a production mode, these options are mainly used for development only. You can use  daemon off  safely in production mode with runit / daemontools however you can't do a graceful upgrade.  master_process off  should never be used in production.

debug_points

语法: debug_points [stop | abort]

缺省值: none

debug_points stop;

There are some assertion points inside nginx that allow to stop nginx to attach the debugger, or to abort and to create the core file.

error_log

语法: error_log file [ debug | info | notice | warn | error | crit ]

缺省值: ${prefix}/logs/error.log

Nginx 添加 --with-debug 编译参数, 你还能够使用以下配置:

error_log LOGFILE [ debug_core | debug_alloc | debug_mutex | debug_event
                    | debug_http | debug_imap];

include

语法: include file | *

缺省值: none

你可以在任意地方使用include指令实现配置文件的包含,如果配置文件很长,这是一个很省事的份模块配置好方法。

include 指令还支持像下面配置一样的全局包含的方法,例如包含一个目录下所有以".conf"结尾的文件:

include vhosts/*.conf;

注意路径受到configure编译参数--prefix=<路径>指令的影响,如果没有指定,Nginx默认是被编译在/usr/local/nginx。

语法: lock_file file

缺省值: compile-time option

lock_file  /var/log/lock_file;

nginx uses accept mutex to serialize accept() syscalls. If nginx is built by gcc, Intel C++, or SunPro C++ compilers on i386, amd64, sparc64, and ppc64, then nginx uses the atomic instructions to implement the mutex. In other cases the lock file would be used.

master_process

语法: master_process on | off

缺省值: on

master_process  off;

Do not use the "daemon" and "master_process" directives in a production mode, these options are mainly used for development only.

pid

语法: pid file

缺省值: compile-time option Example:

pid /var/log/nginx.pid;

进程id存储文件。可以使用 kill -HUP cat /var/log/nginx.pid\ 对Nginx进行配置文件重新加载。

ssl_engine

语法: ssl_engine engine

缺省值: system dependent

Here you can set your preferred openssl engine if any available. You can figure out which one do you have with the commandline tool: openssl engine -t

For example:

$ openssl engine -t
(cryptodev) BSD cryptodev engine
     [ available ]
(dynamic) Dynamic engine loading support
     [ unavailable ]

timer_resolution

语法: timer_resolution t

缺省值: none

Example:

timer_resolution  100ms;

The directive allows to decrease number gettimeofday() syscalls. By default gettimeofday() is called after each return from kevent(), epoll, /dev/poll, select(), poll().

But if you need an exact time in logs when logging $upstream_response_time, or $msec variables, then you should use timer_resolution.

user

语法: user user [group]

缺省值: nobody nobody

指定Nginx Worker进程运行用户,默认是nobody帐号。

例如:

user www users;

worker_cpu_affinity

语法: worker_cpu_affinity cpumask [cpumask...]

缺省值: none

Linux only.

With this option you can bind the worker process to a CPU, it calls sched_setaffinity().

For example,

worker_proceses     4;
worker_cpu_affinity 0001 0010 0100 1000;

Bind each worker process to one CPU only.

worker_proceses     2;
worker_cpu_affinity 0101 1010;

Bind the first worker to CPU0/CPU2, bind the second worker to CPU1/CPU3. This is suitable for HTT.

worker_priority

语法: worker_priority [-]number

缺省值: on

With this option you can give to all worker processes the priority (nice) you need/wish, it calls setpriority().

worker_processes

语法: worker_processes number

缺省值: 1

e.g.:

worker_processes 5;

nginx has the ability to use more than one worker process for several reasons:

  1. to use SMP
  2. to decrease latency when workers blockend on disk I/O
  3. to limit number of connections per process when select()/poll() is used

The worker_processes and worker_connections from the event sections allows you to calculate maxclients value:

max_clients = worker_processes * worker_connections

worker_rlimit_core

语法: worker_rlimit_core size

缺省值: '

Maximum size of core file per worker;

worker_rlimit_nofile

语法: worker_rlimit_nofile limit 缺省值: '

Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_sigpending

语法: worker_rlimit_sigpending limit 缺省值: '

(Since Linux 2.6.8) Specifies the limit on the number of signals that may be queued for the real user ID of the calling process.

working_directory

语法: working_directory path 缺省值: --prefix

This is the working directory for the workers. It's used for core files only. nginx uses absolute paths only, all relative paths in configuration files are relative to --prefix==PATH.

References

NginxChsHttpMainModule (last edited 2008-05-24 18:17:45 by simonlin)