{"id":62,"date":"2020-10-22T15:50:58","date_gmt":"2020-10-22T07:50:58","guid":{"rendered":"https:\/\/www.92k.xin\/?p=62"},"modified":"2020-10-27T19:54:16","modified_gmt":"2020-10-27T11:54:16","slug":"nginx%e5%8f%82%e6%95%b0%e9%85%8d%e7%bd%ae%e8%b0%83%e4%bc%98","status":"publish","type":"post","link":"https:\/\/www.92k.xin\/?p=62","title":{"rendered":"Nginx\u57fa\u7840\u53c2\u6570\u914d\u7f6e\u8c03\u4f18"},"content":{"rendered":"\n
Nginx\u57fa\u7840\u53c2\u6570\u914d\u7f6e\u4f18\u5316\uff0c\u5148\u4e0a\u57fa\u7840\u914d\u7f6e\uff0c\u540e\u9762\u6bb5\u843d\u8be6\u7ec6\u63cf\u8ff0\u3002<\/p>\n\n\n\n
user nobody;\nworker_processes auto;\nworker_cpu_affinity auto;\nworker_rlimit_nofile 65536;\nerror_log \/dev\/null;\nevents {\n worker_connections 10240;\n multi_accept on;\n use epoll;\n}\n\nhttp {\n\tinclude mime.types;\n\tdefault_type text\/html;\n\tsendfile on;\n\tkeepalive_timeout 65;\n\tgzip on;\n\tserver_names_hash_bucket_size 128;\n\tclient_header_buffer_size 4k;\n\tlarge_client_header_buffers 4 32k;\n\tclient_max_body_size 8m;\n\ttcp_nopush on;\n\topen_file_cache max=102400 inactive=20s;\n\topen_file_cache_valid 30s;\n\topen_file_cache_min_uses 1;\n\ttcp_nodelay on;\n\tfastcgi_connect_timeout 300;\n\tfastcgi_send_timeout 300;\n\tfastcgi_read_timeout 300;\n\tfastcgi_buffer_size 64k;\n\tfastcgi_buffers 4 64k;\n\tfastcgi_busy_buffers_size 128k;\n\tfastcgi_temp_file_write_size 128k;\n\tgzip_disable \"MSIE [1-6].\";\n\tgzip_min_length 1k;\n\tgzip_buffers 4 16k;\n\tgzip_http_version 1.0;\n\tgzip_comp_level 9;\n\tgzip_types image\/jpeg image\/gif image\/png text\/javascript text\/plain application\/x-javascript text\/css application\/xml;\n\tgzip_vary on;\n#\u5177\u4f53SERVER\u914d\u7f6e\u6682\u65f6\u7701\u7565\uff0c\u540e\u7eed\u5355\u72ec\u8bb2\u89e3\n}<\/pre><\/div>\n\n\n\n\u6838\u5fc3\u6a21\u5757\u8bb2\u89e3\uff1a\u5177\u4f53\u53c2\u8003\u5f15\u7528\uff1ahttp:\/\/nginx.org\/en\/docs\/ngx_core_module.html<\/a><\/p>\n\n\n\n1\u3001\u5de5\u4f5c\u7528\u6237\uff08user\uff09\uff1a\u4e00\u822c\u65b0\u5efa\u7528\u6237\u6216\u8005nobody\uff0c\u4fdd\u8bc1\u670d\u52a1\u5668\u5b89\u5168\u3002<\/p>\n\n\n\n
2\u3001\u5de5\u4f5c\u7ebf\u7a0b\u6570(worker_processes)\uff1a\u5b9a\u4e49\u5de5\u4f5c\u8fdb\u7a0b\u6570\u3002 auto:\u4f1a\u6839\u636e\u7cfb\u7edfcpu\u4e2a\u6570\u81ea\u52a8\u8c03\u6574\uff0c\u65b9\u4fbf\u6211\u4eec\u5728\u4f7f\u7528\u4e91\u673a\u5668\u7684\u65f6\u5019\u8c03\u6574\u4e86\u5185\u6838\u4e2a\u6570\uff0c\u673a\u5668\u91cd\u542f\u751f\u6548\u540e\uff0c\u8fd9\u91cc\u7684\u53c2\u6570\u8fd8\u9700\u8981\u8c03\u6574\u3002<\/p>\n\n\n\n
3\u3001CPU\u4eb2\u6838\u529b(worker_cpu_affinity):\u8fd9\u4e2a\u53c2\u6570\u6307\u5b9a\u7684\u662fNginx\u7684\u5de5\u4f5c\u7ebf\u7a0b\u5728\u90a3\u4e9bCPU\u6838\u4e0a\u8dd1\u3002 \u5177\u4f53\u53c2\u8003\uff1ahttp:\/\/nginx.org\/en\/docs\/ngx_core_module.html#worker_cpu_affinity<\/a><\/p>\n\n\n\n4\u3001\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u8fde\u63a5\u5904\u7406(use)\uff1a\u8fd9\u4e2a\u662f\u6307\u5b9anginx\u7684\u5de5\u4f5c\u8fde\u63a5\u5904\u7406\u65b9\u5f0f\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003\uff1ahttp:\/\/nginx.org\/en\/docs\/events.html<\/a> <\/p>\n\n\n\nselect<\/strong><\/code> \u6807\u51c6\u65b9\u6cd5\u3002\u652f\u6301\u6a21\u5757\u662f\u5728\u7f3a\u5c11\u66f4\u6709\u6548\u65b9\u6cd5\u7684\u5e73\u53f0\u4e0a\u81ea\u52a8\u6784\u5efa\u7684\u3002\u7684--with-select_module<\/code>\u548c --without-select_module<\/code>\u914d\u7f6e\u53c2\u6570\u53ef\u4ee5\u7528\u6765\u5f3a\u5236\u5730\u542f\u7528\u6216\u7981\u7528\u8be5\u6a21\u5757\u7684\u7248\u672c\u3002<\/li>poll<\/strong><\/code> \u6807\u51c6\u65b9\u6cd5\u3002\u652f\u6301\u6a21\u5757\u662f\u5728\u7f3a\u5c11\u66f4\u6709\u6548\u65b9\u6cd5\u7684\u5e73\u53f0\u4e0a\u81ea\u52a8\u6784\u5efa\u7684\u3002\u7684--with-poll_module<\/code>\u548c --without-poll_module<\/code>\u914d\u7f6e\u53c2\u6570\u53ef\u4ee5\u7528\u6765\u5f3a\u5236\u5730\u542f\u7528\u6216\u7981\u7528\u8be5\u6a21\u5757\u7684\u7248\u672c\u3002<\/li>kqueue<\/strong><\/code> \u5728FreeBSD 4.1 +\uff0cOpenBSD 2.9 +\uff0cNetBSD 2.0\u548cmacOS\u4e0a\u4f7f\u7528\u7684\u6709\u6548\u65b9\u6cd5\u3002<\/li>epoll<\/strong><\/code> \u5728Linux 2.6+\u4e0a\u4f7f\u7528\u7684\u6709\u6548\u65b9\u6cd5\u3002\u8be5EPOLLRDHUP<\/code>\uff08Linux\u76842.6.17\uff0cglibc\u76842.8\uff09\u548cEPOLLEXCLUSIVE<\/code>\uff084.5\u7684Linux\uff0cglibc\u76842.24\uff09\u6807\u5fd71.11.3\u4ee5\u6765\u7684\u652f\u6301\u3002\u4e00\u4e9b\u8f83\u65e7\u7684\u53d1\u884c\u7248\uff08\u5982SuSE 8.2\uff09\u63d0\u4f9b\u7684\u4fee\u8865\u7a0b\u5e8f\u53ef\u4e3a2.4\u5185\u6838\u589e\u52a0epoll\u652f\u6301\u3002<\/li>\/dev\/poll<\/strong><\/code> \u5728Solaris 7 11\/99 +\uff0cHP \/ UX 11.22+\uff08\u4e8b\u4ef6\u7aef\u53e3\uff09\uff0cIRIX 6.5.15+\u548cTru64 UNIX 5.1A +\u4e0a\u4f7f\u7528\u7684\u6709\u6548\u65b9\u6cd5\u3002<\/li>eventport<\/strong><\/code> \u4e8b\u4ef6\u7aef\u53e3\uff0cSolaris 10+\u4e0a\u4f7f\u7528\u7684\/dev\/poll<\/code>\u65b9\u6cd5\uff08\u7531\u4e8e\u5df2\u77e5\u95ee\u9898\uff0c\u5efa\u8bae\u6539\u7528\u8be5\u65b9\u6cd5\uff09\u3002<\/li><\/ul>\n\n\n\nHttp\u6a21\u5757\u4f18\u5316\uff0c\u8fd9\u91cc\u4e3b\u8981\u53c2\u8003\uff1ahttp:\/\/nginx.org\/en\/docs\/http\/ngx_http_core_module.html<\/a><\/p>\n\n\n\n<\/p>\n\n\n\n
fastcgi_* \uff1a\u9488\u5bf9fastcgi\u8fdb\u884c\u53c2\u6570\u4f18\u5316\u3002<\/p>\n\n\n\n
gzip_* \uff1a\u9488\u5bf9\u5185\u5bb9\u4f20\u9001\u5f00\u542f\u538b\u7f29\u4f20\u9001 \u53c2\u6570\u4f18\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Nginx\u57fa\u7840\u53c2\u6570\u914d\u7f6e\u4f18\u5316\uff0c\u5148\u4e0a\u57fa\u7840\u914d\u7f6e\uff0c\u540e\u9762\u6bb5\u843d\u8be6\u7ec6\u63cf\u8ff0\u3002 user nobody; worker_proc… <\/p>\n