nginx ngx_core_module(main event)

例子

user www www;
worker_processes 2;

error_log /var/log/nginx-error.log info;

events {
    use kqueue;
    worker_connections 2048;
}

main

语法默认描述
daemon on | off;ondaemon
debug_points abort | stop;debug
env variable[=value];TZ;默认nginx会移除所有环境变量,这里可以设置环境变量
error_log file [level];logs/error.log error;日志文件,还可以用于http,mail,stream,server.location
events { … }连接设置
include file | mask;包含另一个conf文件(可用于其他所有块指令)
load_module file;加载其他模块
lock_file file;logs/nginx.lock;?
master_process on | off;on
pcre_jit on | off;offjit编译,提高正则表达式的解析
pid file;logs/nginx.pid指定存放pid信息
ssl_engine device;Defines the name of the hardware SSL accelerator
thread_pool name threads=number [max_queue=number];default threads=32 max_queue=65536;线程池
timer_resolution interval;
user user [group];nobody nobody;设置用户(user)和分组(group),分组可以不填,使用user所在的组
worker_cpu_affinity auto [cpumask];
worker_priority number;0worker的优先级
worker_processes number | auto;1worker的最大数量
worker_rlimit_core size;Changes the limit on the largest size of a core file (RLIMIT_CORE) for worker processes.
worker_rlimit_nofile number;Changes the limit on the maximum number of open files (RLIMIT_NOFILE) for worker processes.
worker_shutdown_timeout time;When the time expires, nginx will try to close all the connections currently open to facilitate shutdown.
working_directory directory;Defines the current working directory for a worker process.

1.mian一般只配置一个user,默认user是nobody group是nobody,可以改成特定用户的名字,比如root root,或者其他用户名
2.nobody只有读的权限(既权限中的other中设置可读的文件)
3.root可以监听小于1024的端口(web一般都是80),普通用户和nobody都不行

event

语法默认描述
accept_mutex on | off;off如果no,则加锁所有worker顺序访问
accept_mutex_delay time;500ms当另一个worker接收连接后,下一个接收连接的延迟
debug_connection address | CIDR | unix:;为指定客户端开启debug
multi_accept on | off;off关闭时,每个worker一次接受一个连接,开启每个worker一次接收多个连接
use method;
worker_aio_requests number;32
worker_connections number;512最大的连接数

参考:
http://nginx.org/en/docs/ngx_core_module.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值