nginx優化
- user www; #安全性優化,不建議採用root
- pid /var/run/nginx.pid;
- worker_processes 4; #建議將邏輯cpu空閒的都分給它
- worker_cpu_affinity 0001 0010 0100 1000; #將邏輯核和nginx線程作綁定,這個有幾個核心就有多少位
- worker_rlimit_nofile 100000; #每一個進程能夠打開的文件數
- events {
- worker_connections 2048; #最大鏈接數
- multi_accept on;
- use epoll; #使用非阻塞模型
- }
- http {
- server_tokens off;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- access_log off; #關閉accesslog
- error_log /var/log/nginx/error.log crit; #error日誌級別開大
- keepalive_timeout 10;
- client_header_timeout 10;
- client_body_timeout 10;
- reset_timedout_connection on;
- send_timeout 10;
- limit_conn_zone $binary_remote_addr zone=addr:5m;
- limit_conn addr 100;
- include /etc/nginx/mime.types;
- default_type text/html;
- charset UTF-8;
- gzip on;
- gzip_disable "msie6";
- gzip_proxied any;
- gzip_min_length 1000;
- gzip_comp_level 6;
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
- open_file_cache max=100000 inactive=20s; #讓文件存在緩存裏
- open_file_cache_valid 30s;
- open_file_cache_min_uses 2;
- open_file_cache_errors on;
- include /etc/nginx/conf.d/*.conf;
- include /etc/nginx/sites-enabled/*;
- }
歡迎關注本站公眾號,獲取更多信息