启动nginx出现,nginx: [warn] 1024 worker_connections exceed open file resource limit: 256,错误时。
worker_connections: 单个后台worker process进程的最大并发链接数worker_connections; open file resource limit: linux中process可以打开的文件句柄数量;
nginx config:
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/log/nginx/nginx.pid;
events {
worker_connections 1024;
}
... 控制台执行:ulimit -a,显示如下,将红色字的变量改为1024即可,使用命令ulimit -n 1024。core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited