sendfile on; #特殊的数据传输功能php
tcp_nopush on;node
参数sendfile on 用于开启文件高效传输模式,同时将tcp_nopush on 和tcp_nodelay on 两个指令设置为on,可防止网络及磁盘I/O阻塞,提高Nginx工做效率nginx
参数语法 sendfile on | off;性能优化
放置位置 http,server,location,if in locationbash
参数语法 tcp_nopush on | off;服务器
放置位置 http,server,location网络
参数语法 tcp_nodelay on | off;app
放置位置 http,server,locationtcp
在主配置文件nginx.conf中配置ide
worker_processes 2; worker_cpu_affinity 0101 1010; error_log logs/error.log; #配置Nginx worker进程最大打开文件数 worker_rlimit_nofile 65535; user www www; events { #单个进程容许的客户端最大链接数 worker_connections 20480; #使用epoll模型 use epoll; } http { include mime.types; default_type application/octet-stream; #sendfile on; keepalive_timeout 65; #访问日志配置 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #虚拟主机 include /application/nginx/conf/extra/www.conf; include /application/nginx/conf/extra/blog.conf; include /application/nginx/conf/extra/bbs.conf; include /application/nginx/conf/extra/edu.conf; include /application/nginx/conf/extra/phpmyadmin.conf; include /application/nginx/conf/extra/status.conf; #nginx优化---------------------- #隐藏版本号 server_tokens on; #优化服务器域名的散列表大小 server_names_hash_bucket_size 64; server_names_hash_max_size 2048; #开启高效文件传输模式 sendfile on; #减小网络报文段数量 #tcp_nopush on; #提升I/O性能 tcp_nodelay on; }