#yyds干货盘点#Nginx的核心配置

【#yyds干货盘点#Nginx的核心配置】冲天香阵透长安,满城尽带黄金甲。这篇文章主要讲述#yyds干货盘点#Nginx的核心配置相关的知识,希望能为你提供帮助。
1.全局配置 1.1 CPU内核的绑定

[root@c7-147 ~]# lscpu |grep -i cpu CPU op-mode(s):32-bit, 64-bit CPU(s):4# 添加CPU核的个数 On-line CPU(s) list:0-3 CPU family:6 Model name:Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz CPU MHz:2903.998 NUMA node0 CPU(s):0-3 [root@c7-147 html]# ps -ef |grep nginx#开启nginx root258610 03:02 ?00:00:00 nginx: master process /apps/nginx/sbin/nginx nginx258725860 03:02 ?00:00:00 nginx: worker process root311222420 05:42 pts/000:00:00 grep --color=auto nginx # [root@c7-147 ~]# cat /apps/nginx/conf/nginx.conf #usernobody; worker_processes4; #4个核同时安排 worker_cpu_affinity auto; #自动排序 #重启nginx [root@c7-147 ~]# systemctl restart nginx #客服端发送请求 [root@localhost rc.d]# while true; do curl http://10.0.0.147/index.html; sleep 0.5; done # 服务端查看是哪些CPU的核在发生变化情况 [root@c7-147 ~]# watch -n1 ps -axo pid,cmd,nice,psr | grep nginx

1.2 错误日志
[root@c7-147 ~]# ulimit -n 1024 [root@c7-147 ~]# ulimit -n 1048576#最多打开这么多(2*20) [root@c7-147 ~]# ulimit -n 1048577 -bash: ulimit: open files: cannot modify limit: Operation not permitted [root@c7-147 ~]# cat /etc/security/limits.conf # /etc/security/limits.conf # #This file sets the resource limits for the users logged in via PAM.

1.3
[root@c7-147 ~]# grep master* /apps/nginx/conf/nginx.conf master_process off; #默认是on,关闭以后就只有一个主进程,性能很差 [root@c7-147 ~]# systemctl restart nginx [root@c7-147 ~]# ps -ef |grep nginx#开启以后都只有一个主进程了 root670010 06:38 ?00:00:00 /apps/nginx/sbin/nginx root670213340 06:38 pts/000:00:00 grep --color=auto nginx

1.4httpd配置详解


    推荐阅读