nginx配置详解之main模块

本文详细探讨了Nginx的main模块配置,包括user指令用于指定Nginx运行用户,worker_processes设定启动进程数,建议设置为CPU核心数,error_log配置错误日志并说明如何关闭日志,以及worker_rlimit_nofile参数用于设置最大打开文件限制数,最后提到了pid文件路径的作用。

nginx常用全局配置如下:

user nginx;
worker_processes = 1;
error_log  /var/log/nginx/error.log;
worker_rlimit_nofile 20000;
pid        /var/run/nginx.pid;

以下为各配置参数的详细作用:


user nginx;

#指定nginx用户


worker_processes = 1;

#启动进程数 通常跟cpu数相等 如不清楚可以设置为auto自动监测 如果想知道自己的系统是几核的 可以用下列命令

cat /proc/cpuinfo 
输出如下
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 45
model name	: Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
stepping	: 7
microcode	: 1808
cpu MHz		: 2300.091
cache size	: 15360 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush mmx fxsr sse 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值