nginx優化

  1. user www;                                                                #安全性優化,不建議採用root
  2. pid /var/run/nginx.pid; 
  3. worker_processes 4;                                                 #建議將邏輯cpu空閒的都分給它
  4. worker_cpu_affinity    0001  0010  0100 1000;        #將邏輯核和nginx線程作綁定,這個有幾個核心就有多少位
  5. worker_rlimit_nofile 100000;                                    #每一個進程能夠打開的文件數
  6. events { 
  7. worker_connections 2048;                                        #最大鏈接數
  8. multi_accept on;                                                            
  9. use epoll;                                                                   #使用非阻塞模型
  10. http { 
  11. server_tokens off; 
  12. sendfile on; 
  13. tcp_nopush on; 
  14. tcp_nodelay on; 
  15. access_log off;                                                           #關閉accesslog
  16. error_log /var/log/nginx/error.log crit;                   #error日誌級別開大
  17. keepalive_timeout 10; 
  18. client_header_timeout 10; 
  19. client_body_timeout 10; 
  20. reset_timedout_connection on; 
  21. send_timeout 10; 
  22. limit_conn_zone $binary_remote_addr zone=addr:5m; 
  23. limit_conn addr 100; 
  24. include /etc/nginx/mime.types; 
  25. default_type text/html; 
  26. charset UTF-8; 
  27. gzip on; 
  28. gzip_disable "msie6"; 
  29. gzip_proxied any; 
  30. gzip_min_length 1000; 
  31. gzip_comp_level 6; 
  32. gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
  33. open_file_cache max=100000 inactive=20s;                    #讓文件存在緩存裏
  34. open_file_cache_valid 30s; 
  35. open_file_cache_min_uses 2; 
  36. open_file_cache_errors on; 
  37. include /etc/nginx/conf.d/*.conf; 
  38. include /etc/nginx/sites-enabled/*; 
相關文章
相關標籤/搜索