centos76 系统nginx-1233 高性能高并发的 nginxconf
以下是一个基本的 nginx.conf 配置文件,用于 CentOS 7.6 系统和 nginx-1.23.3 版本的高性能高并发服务器:
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
}
该配置文件中,user 指定了 nginx 进程的运行用户,这里设为 nginx 用户;worker_processes 指定了 nginx 进程的数量,这里使用 auto 自动调整;worker_cpu_affinity 指定了 nginx 进程的 CPU 亲和性,这里使用 auto 自动调整;pid 指定了 nginx 进程的 PID 文件路径。
events 块指定了 nginx 的事件模型,这里 worker_connections 指定了每个 worker 进程可以处理的最大连接数。
http 块是 nginx 的 HTTP 配置,这里 include 指定了 MIME 类型文件的路径,default_type 指定了默认的 MIME 类型,sendfile 开启了 sendfile 功能,tcp_nopush 和 tcp_nodelay 开启了 TCP NoPush 和 NoDelay 功能,keepalive_timeout 指定了 keep-alive 连接的超时时间,types_hash_max_size 指定了 MIME 类型哈希表的最大尺寸。
server 块指定了一个虚拟主机,这里 listen 指定了监听的端口,server_name 指定了虚拟主机的域名,root 指定了虚拟主机的根目录,index 指定了默认的索引文件。
location 块指定了访问虚拟主机的 URL,这里 try_files 指定了查找文件的顺序,当请求的文件不存在时,会尝试查找其他文件。
原文地址: https://www.cveoy.top/t/topic/bd3s 著作权归作者所有。请勿转载和采集!