1 debug_points
语法:debug_points [start|stop]
默认值:none
eg:debug_points stop; //关闭调试选项
作用:用于调试,在调试器内设置断点
2 error_log
语法:error_log file [debug|info|notice|warn|error|crit]
默认值:${prefix}/logs/error.log
eg:error_log /var/logs/error.log; //设置错误日志的路径
作用:用于记录服务器的一些错误信息
3 include
语法:include file
默认值:none
eg:include vhost/*
作用:用于加载其它的配置文件
4 pid
语法:pid file
默认值:on
eg:pid /var/log/nginx.pid
作用:记录nginx的进程号,可以通过kill发送信号给该ID,完成nginx的平滑重启
5 ssl_engine
语法:ssl_engine engine
默认值:系统默认依赖的engine
eg:ssl_engine rdrand
作用:设置ssl的首选engine,可以使用openssl engine -t 查看当前系统支持的engine
6 timer_resolution
语法:timer_resolution t
默认值:none
eg:timer_resolution 10ms
作用:可以减少gettimeofday函数获取当前时间的系统调用次数,默认情况下,它会在每一次kevent,epoll,/dev/poll,select(),poll()返回时被调用,若需要准确的记录ms级别的准确时间或者反向代理响应时间,可以用这个指令
8 user
语法:user user [group]
默认值:nobody nobody
eg:tuser www www
作用:用于指定nginx进程的用户和用户组,默认都是nobody
9 worker_process
语法:worker_process num
默认值:1
eg:worker_process 5;
作用:1)可以使用SMP对称多处理技术,充分发挥多核cpu的优势
2)可以检测进程在磁盘IO阻塞上的延迟时间
3)使用select或者poll模型时,能够限制每个进程的连接数
woker_rlimit_core用于指定每个nginx进程最大的core文件大小
worker_rlimit_nofile用于指定nginx进程可以打开的最大文件描述符的数量
事件模块的相关指令:
1 accept_mutex
语法:ccept_mutex [on|off]
默认值:on
作用:nginx使用连接互斥锁进行顺序的accept()系统调用
2 accept_mutex_delay
语法:accept_mutex_delay Nms
默认值:500
作用:若一个工作进程没有互斥锁,它将在最少Nms延迟之后再次尝试获取,默认时间为500ms
3 use
语法:use [kqueue|rtsig|dev/poll|select|epoll|poll|eventport]
默认值:
作用:指定使用的事件模型,freebsd4.1以上的系统推荐kqueue Linux2.6以上推荐epoll
solaris推荐eventport
4 worker_connections
语法:worker_connections num
作用:设置每个工作进程可以处理的最大连接数
通过worker_processes和worker_connections可以计算出nginx服务器可以处理的最大连接数
max_clients=worker_processes*worker_connections
假设开启8个worker进程,connections设置为100 max_clients=100*8是达不到的,实际上会是100*8/4=200
因为浏览器通常默认打开2个与服务器的连接
而nginx使用同一个文件描述符池中的描述符来连接后端