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; }