1 nginx.conf的events,http段一般固定配置 2 user nobody nobody; #使用的用户可以按照实际情况修改 3 worker_processes 2; #指定nginx开启的进程数,将其设置为可用的CPU内核数将是一个好的开始 4 error_log /usr/local/nginx/logs/nginx_error.log crit; 5 pid /usr/local/nginx/logs/nginx.pid; 6 worker_rlimit_nofile 51200; #更改worker进程的最大打开文件数限制。设置后你的操作系统和Nginx可以处理比“ulimit -a”更多的文件,所以把这个值设高,这样nginx就不会有“too many open files”问题了。 7 events 8 { 9 use epoll; 10 worker_connections 6000; 11 } 12 http 13 14 { 15 include mime.types; 16 default_type application/octet-stream; 17 server_names_hash_bucket_size 3526; 18 server_names_hash_max_size 4096; 19 log_format combined_realip ‘$remote_addr $http_x_forwarded_for [$time_local]‘ 20 ‘$host "$request_uri" $status‘ 21 ‘"$http_referer" "$http_user_agent"‘; 22 sendfile on; 23 tcp_nopush on; 24 keepalive_timeout 30; 25 client_header_timeout 3m; 26 client_body_timeout 3m; 27 send_timeout 3m; 28 connection_pool_size 256; 29 client_header_buffer_size 1k; 30 large_client_header_buffers 8 4k; 31 request_pool_size 4k; 32 output_buffers 4 32k; 33 postpone_output 1460; 34 client_max_body_size 10m; 35 client_body_buffer_size 256k; 36 client_body_temp_path /usr/local/nginx/client_body_temp; 37 proxy_temp_path /usr/local/nginx/proxy_temp; 38 #fastcgi_temp_path /usr/local/nginx/fastcgi_temp; 39 #fastcgi_intercept_errors on; 40 tcp_nodelay on; 41 gzip on; 42 gzip_min_length 1k; 43 gzip_buffers 4 8k; 44 gzip_comp_level 5; 45 gzip_http_version 1.1; 46 gzip_types text/plain application/x-javascript text/css text/htm application/xml; 47 include vhosts/*.conf; (虚拟主机) 48 }
时间: 2024-10-16 00:16:46