{"id":1120,"date":"2012-10-09T16:43:03","date_gmt":"2012-10-09T08:43:03","guid":{"rendered":"http:\/\/www.huzs.top\/?p=1120"},"modified":"2012-10-09T16:43:03","modified_gmt":"2012-10-09T08:43:03","slug":"php-fpm%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.huzs.top\/?p=1120","title":{"rendered":"PHP FPM\u8bbe\u7f6e"},"content":{"rendered":"<p>php-fpm\u76ee\u524d\u4e3b\u8981\u53c8\u4e24\u4e2a\u5206\u652f\uff0c\u5206\u522b\u5bf9\u5e94\u4e8ephp-5.2.x\u7684\u7248\u672c\u548cphp-5.3.x\u7684\u7248\u672c\u3002\u57285.2.x\u7684\u7248\u672c\u4e2d\uff0cphp-fpm.conf\u4f7f\u7528\u7684\u662fxml\u683c\u5f0f\uff0c\u800c\u5728\u65b0\u76845.3.x\u7248\u672c\u4e2d\uff0c\u5219\u662f\u548cphp.ini\u4e00\u6837\u7684\u914d\u7f6e\u98ce\u683c\u3002\\n\\n\u57285.2.x\u7248\u672c\u4e2d\uff0cphp-fpm.conf\u4e2d\u5bf9\u4e8e\u8fdb\u7a0b\u7ba1\u7406\u53f7\u79f0\u662f\u6709\u4e24\u79cd\u98ce\u683c\uff0c\u4e00\u79cd\u662f\u9759\u6001(static)\u7684\uff0c\u4e00\u79cd\u662f\u7c7b\u4f3c\u4e8eapache\u98ce\u683c(apache-like)\u7684\u3002\\n\\n<\/p>\n<blockquote><p>Sets style of controling worker process count.\\nValid values are \u2019static\u2019 and \u2018apache-like\u2019\\n< value name=\u201dstyle\u201d>static< \/ value><\/p><\/blockquote>\n<p>\\n\\n\u6309\u7167\u6587\u6863\u7684\u8bf4\u660e\uff0c\u5982\u679cpm\u7684style\u91c7\u7528apache-like\uff0c\u542f\u52a8\u7684\u8fdb\u7a0b\u6570\u5e94\u8be5\u662f\u548cStartServers\u6307\u5b9a\u7684\u4e00\u6837\u3002\u4e0d\u8fc7\u7ecf\u8fc7\u6570\u6b21\u7684\u5c1d \u8bd5\uff0c\u4f1a\u53d1 \u73b0\uff0c\u5b9e\u9645\u4e0a\u5728\u8fd9\u91cc\u5c06pm\u7684style\u914d\u7f6e\u6210apache-like\u6ca1\u6709\u8d77\u4efb\u4f55\u4f5c\u7528\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u91cc\u7684apache-like\u5e76\u6ca1\u6709\u88ab\u5b9e\u73b0\u3002\\n<!--more-->\\n\u4e0d\u8fc7\uff0c\u5728\u6700\u65b0\u76845.3.x\u7684\u914d\u5957php-fpm\u4e2d\uff0capache\u98ce\u683c\u7684\u8fdb\u7a0b\u7ba1\u7406\u5df2\u7ecf\u88ab\u5b9e\u73b0\u4e86\u3002\\n<\/p>\n<pre>\\n; Choose how the process manager will control the number of child processes.\\n; Possible Values:\\n; static - a fixed number (pm.max_children) of child processes;\\n; dynamic - the number of child processes are set dynamically based on the\\n; following directives:\\n; pm.max_children - the maximum number of children that can\\n; be alive at the same time.\\n; pm.start_servers - the number of children created on startup.\\n; pm.min_spare_servers - the minimum number of children in 'idle'\\n; state (waiting to process). If the number\\n; of 'idle' processes is less than this\\n; number then some children will be created.\\n; pm.max_spare_servers - the maximum number of children in 'idle'\\n; state (waiting to process). If the number\\n; of 'idle' processes is greater than this\\n; number then some children will be killed.\\n; Note: This value is mandatory.\\n;pm = dynamic\\npm = static<\/pre>\n<p>\\n\u7531\u4e0a\u9762\u4e00\u6bb5\u6587\u5b57\u53ef\u77e5\uff0c\u5bf9\u4e8e\u8fdb\u7a0b\u7684\u7ba1\u7406\u5b58\u5728\u4e24\u79cd\u98ce\u683c\u2014\u2014static\u548cdynamic\u3002\u548c\u4e4b\u524d\u7684\u7248\u672c\u7684\u8fdb\u7a0b\u7ba1\u7406\u5176\u5b9e\u8fd8\u662f\u4e00\u6837\u7684\uff0c\u53ea\u662f\u5c06apache-like\u6539\u6210\u4e86dynamic\uff0c\u8fd9\u6837\u66f4\u5bb9\u6613\u7406\u89e3\u3002\\n\\n\u5982 \u679c\u8bbe\u7f6e\u6210static\uff0cphp-fpm\u8fdb\u7a0b\u6570\u81ea\u59cb\u81f3\u7ec8\u90fd\u662fpm.max_children\u6307\u5b9a\u7684\u6570\u91cf\uff0c\u4e0d\u518d\u589e\u52a0\u6216\u51cf\u5c11\u3002\u5982\u679c\u8bbe\u7f6e\u6210 dynamic\uff0c\u5219php-fpm\u8fdb\u7a0b\u6570\u662f\u52a8\u6001\u7684\uff0c\u6700\u5f00\u59cb\u662fpm.start_servers\u6307\u5b9a\u7684\u6570\u91cf\uff0c\u5982\u679c\u8bf7\u6c42\u8f83\u591a\uff0c\u5219\u4f1a\u81ea\u52a8\u589e\u52a0\uff0c \u4fdd\u8bc1\u7a7a\u95f2\u7684\u8fdb\u7a0b\u6570\u4e0d\u5c0f\u4e8epm.min_spare_servers\uff0c\u5982\u679c\u8fdb\u7a0b\u6570\u8f83\u591a\uff0c\u4e5f\u4f1a\u8fdb\u884c\u76f8\u5e94\u6e05\u7406\uff0c\u4fdd\u8bc1\u591a\u4f59\u7684\u8fdb\u7a0b\u6570\u4e0d\u591a\u4e8e pm.max_spare_servers\u3002\\n\\n\u8fd9\u4e24\u79cd\u4e0d\u540c\u7684\u8fdb\u7a0b\u7ba1\u7406\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6839\u636e\u670d\u52a1\u5668\u7684\u5b9e\u9645\u9700\u6c42\u6765\u8fdb\u884c\u8c03\u6574\u3002\\n\\n\u8fd9\u91cc\u5148\u8bf4\u4e00\u4e0b\u6d89\u53ca\u5230\u8fd9\u4e2a\u7684\u51e0\u4e2a\u53c2\u6570\uff0c\u4ed6\u4eec\u5206\u522b\u662fpm\u3001pm.max_children\u3001pm.start_servers\u3001pm.min_spare_servers\u548cpm.max_spare_servers\u3002\\n\\npm\u8868\u793a\u4f7f\u7528\u90a3\u79cd\u65b9\u5f0f\uff0c\u6709\u4e24\u4e2a\u503c\u53ef\u4ee5\u9009\u62e9\uff0c\u5c31\u662fstatic\uff08\u9759\u6001\uff09\u6216\u8005dynamic\uff08\u52a8\u6001\uff09\u3002\u5728\u66f4\u8001\u4e00\u4e9b\u7684\u7248\u672c\u4e2d\uff0cdynamic\u88ab\u79f0\u4f5capache-like\u3002\u8fd9\u4e2a\u8981\u6ce8\u610f\u770b\u914d\u7f6e\u6587\u4ef6\u7684\u8bf4\u660e\u3002\\n\\n\u4e0b\u97624\u4e2a\u53c2\u6570\u7684\u610f\u601d\u5206\u522b\u4e3a\uff1a\\npm.max_children\uff1a\u9759\u6001\u65b9\u5f0f\u4e0b\u5f00\u542f\u7684php-fpm\u8fdb\u7a0b\u6570\u91cf\u3002\\npm.start_servers\uff1a\u52a8\u6001\u65b9\u5f0f\u4e0b\u7684\u8d77\u59cbphp-fpm\u8fdb\u7a0b\u6570\u91cf\u3002\\npm.min_spare_servers\uff1a\u52a8\u6001\u65b9\u5f0f\u4e0b\u7684\u6700\u5c0fphp-fpm\u8fdb\u7a0b\u6570\u91cf\u3002\\npm.max_spare_servers\uff1a\u52a8\u6001\u65b9\u5f0f\u4e0b\u7684\u6700\u5927php-fpm\u8fdb\u7a0b\u6570\u91cf\u3002\\n\\n\u5982\u679cdm\u8bbe\u7f6e\u4e3astatic\uff0c\u90a3\u4e48\u5176\u5b9e\u53ea\u6709pm.max_children\u8fd9\u4e2a\u53c2\u6570\u751f\u6548\u3002\u7cfb\u7edf\u4f1a\u5f00\u542f\u8bbe\u7f6e\u6570\u91cf\u7684php-fpm\u8fdb\u7a0b\u3002\u5982\u679cdm\u8bbe\u7f6e\u4e3a dynamic\uff0c\u90a3\u4e48pm.max_children\u53c2\u6570\u5931\u6548\uff0c\u540e\u97623\u4e2a\u53c2\u6570\u751f\u6548\u3002\u7cfb\u7edf\u4f1a\u5728php-fpm\u8fd0\u884c\u5f00\u59cb \u7684\u65f6\u5019\u542f\u52a8pm.start_servers\u4e2aphp-fpm\u8fdb\u7a0b\uff0c\u7136\u540e\u6839\u636e\u7cfb\u7edf\u7684\u9700\u6c42\u52a8\u6001\u5728pm.min_spare_servers\u548c pm.max_spare_servers\u4e4b\u95f4\u8c03\u6574php-fpm\u8fdb\u7a0b\u6570\u3002\\n\\n\u90a3\u4e48\uff0c\u5bf9\u4e8e\u6211\u4eec\u7684\u670d\u52a1\u5668\uff0c\u9009\u62e9\u54ea\u79cd\u6267\u884c\u65b9\u5f0f\u6bd4\u8f83\u597d\u5462\uff1f\u4e8b\u5b9e\u4e0a\uff0c\u8ddfApache\u4e00\u6837\uff0c\u8fd0\u884c\u7684PHP\u7a0b\u5e8f\u5728\u6267\u884c\u5b8c\u6210\u540e\uff0c\u6216\u591a\u6216\u5c11\u4f1a\u6709\u5185\u5b58\u6cc4\u9732\u7684\u95ee\u9898\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5f00\u59cb\u7684\u65f6\u5019\u4e00\u4e2aphp-fpm\u8fdb\u7a0b\u53ea\u5360\u75283M\u5de6\u53f3\u5185\u5b58\uff0c\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\u5c31\u4f1a\u4e0a\u5347\u523020-30M\u7684\u539f\u56e0\u4e86\u3002\\n\\n\u5bf9\u4e8e\u5185\u5b58\u5927\u7684\u670d\u52a1\u5668\uff08\u6bd4\u59828G\u4ee5\u4e0a\uff09\u6765\u8bf4\uff0c\u6307\u5b9a\u9759\u6001\u7684max_children\u5b9e\u9645\u4e0a\u66f4\u4e3a\u59a5\u5f53\uff0c\u56e0\u4e3a\u8fd9\u6837\u4e0d\u9700\u8981\u8fdb\u884c\u989d\u5916\u7684\u8fdb\u7a0b\u6570\u76ee\u63a7\u5236\uff0c\u4f1a\u63d0\u9ad8\u6548 \u7387\u3002\u56e0\u4e3a\u9891\u7e41\u5f00\u5173php-fpm\u8fdb\u7a0b\u4e5f\u4f1a\u6709\u65f6\u6ede\uff0c\u6240\u4ee5\u5185\u5b58\u591f\u5927\u7684\u60c5\u51b5\u4e0b\u5f00\u9759\u6001\u6548\u679c\u4f1a\u66f4\u597d\u3002\u6570\u91cf\u4e5f\u53ef\u4ee5\u6839\u636e \u5185\u5b58\/30M \u5f97\u5230\uff0c\u6bd4\u59828GB\u5185\u5b58\u53ef\u4ee5\u8bbe\u7f6e\u4e3a100\uff0c\u90a3\u4e48php-fpm\u8017\u8d39\u7684\u5185\u5b58\u5c31\u80fd\u63a7\u5236\u5728 2G-3G\u7684\u6837\u5b50\u3002\u5982\u679c\u5185\u5b58\u7a0d\u5fae\u5c0f\u70b9\uff0c\u6bd4\u59821G\uff0c\u90a3\u4e48\u6307\u5b9a\u9759\u6001\u7684\u8fdb\u7a0b\u6570\u91cf\u66f4\u52a0\u6709\u5229\u4e8e\u670d\u52a1\u5668\u7684\u7a33\u5b9a\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1php-fpm\u53ea\u83b7\u53d6\u591f\u7528\u7684\u5185\u5b58\uff0c\u5c06\u4e0d\u591a\u7684 \u5185\u5b58\u5206\u914d\u7ed9\u5176\u4ed6\u5e94\u7528\u53bb\u4f7f\u7528\uff0c\u4f1a\u4f7f\u7cfb\u7edf\u7684\u8fd0\u884c\u66f4\u52a0\u7545\u901a\u3002\\n\\n\u5bf9\u4e8e\u5c0f\u5185\u5b58\u7684\u670d\u52a1\u5668\u6765\u8bf4\uff0c\u6bd4\u5982256M\u5185\u5b58\u7684VPS\uff0c\u5373\u4f7f\u6309\u7167\u4e00\u4e2a20M\u7684\u5185\u5b58\u91cf\u6765\u7b97\uff0c10\u4e2aphp-cgi\u8fdb\u7a0b\u5c31\u5c06\u8017\u6389200M\u5185\u5b58\uff0c\u90a3\u7cfb\u7edf\u7684\u5d29 \u6e83\u5c31\u5e94\u8be5\u5f88\u6b63\u5e38\u4e86\u3002\u56e0\u6b64\u5e94\u8be5\u5c3d\u91cf\u5730\u63a7\u5236php-fpm\u8fdb\u7a0b\u7684\u6570\u91cf\uff0c\u5927\u4f53\u660e\u786e\u5176\u4ed6\u5e94\u7528\u5360\u7528\u7684\u5185\u5b58\u540e\uff0c\u7ed9\u5b83\u6307\u5b9a\u4e00\u4e2a\u9759\u6001\u7684\u5c0f\u6570\u91cf\uff0c\u4f1a\u8ba9\u7cfb\u7edf\u66f4\u52a0\u5e73\u7a33\u4e00\u4e9b\u3002\u6216\u8005 \u4f7f\u7528\u52a8\u6001\u65b9\u5f0f\uff0c\u56e0\u4e3a\u52a8\u6001\u65b9\u5f0f\u4f1a\u7ed3\u675f\u6389\u591a\u4f59\u7684\u8fdb\u7a0b\uff0c\u53ef\u4ee5\u56de\u6536\u91ca\u653e\u4e00\u4e9b\u5185\u5b58\uff0c\u6240\u4ee5\u63a8\u8350\u5728\u5185\u5b58\u8f83\u5c11\u7684\u670d\u52a1\u5668\u6216VPS\u4e0a\u4f7f\u7528\u3002\u5177\u4f53\u6700\u5927\u6570\u91cf\u6839\u636e \u5185\u5b58\/20M \u5f97\u5230\u3002\u6bd4\u5982\u8bf4512M\u7684VPS\uff0c\u5efa\u8baepm.max_spare_servers\u8bbe\u7f6e\u4e3a20\u3002\u81f3\u4e8epm.min_spare_servers\uff0c\u5219\u5efa\u8bae\u6839\u636e\u670d \u52a1\u5668\u7684\u8d1f\u8f7d\u60c5\u51b5\u6765\u8bbe\u7f6e\uff0c\u6bd4\u8f83\u5408\u9002\u7684\u503c\u57285~10\u4e4b\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php-fpm\u76ee\u524d\u4e3b\u8981\u53c8\u4e24\u4e2a\u5206\u652f\uff0c\u5206\u522b\u5bf9\u5e94\u4e8ephp-5.2.x\u7684\u7248\u672c\u548cphp-5.3.x\u7684\u7248\u672c\u3002\u57285.2.x\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1120","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/1120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1120"}],"version-history":[{"count":0,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/1120\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}