{"id":139356,"date":"2019-03-22T08:15:10","date_gmt":"2019-03-22T00:15:10","guid":{"rendered":"https:\/\/gulass.cn\/?p=139356"},"modified":"2019-03-12T09:16:35","modified_gmt":"2019-03-12T01:16:35","slug":"fastcgi-php-fpm","status":"publish","type":"post","link":"https:\/\/gulass.cn\/fastcgi-php-fpm.html","title":{"rendered":"\u7ec6\u8ff0\uff1aFastCgi \u4e0e PHP-FPM \u4e4b\u95f4\u7684\u533a\u522b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nCGI\u662fHTTP Server\u548c\u4e00\u4e2a\u72ec\u7acb\u7684\u8fdb\u7a0b\u4e4b\u95f4\u7684\u534f\u8bae\uff0c\u628aHTTP Request\u7684Header\u8bbe\u7f6e\u6210\u8fdb\u7a0b\u7684\u73af\u5883\u53d8\u91cf\uff0cHTTP Request\u7684\u6b63\u6587\u8bbe\u7f6e\u6210\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u5165\uff0c\u800c\u8fdb\u7a0b\u7684\u6807\u51c6\u8f93\u51fa\u5c31\u662fHTTP Response\u5305\u62ecHeader\u548c\u6b63\u6587;php-fpm\u5c31\u76f8\u5f53\u4e8e\u662fApache+mod_php,\u65e0\u975ephp-fpm\u81ea\u5e26\u4e86FASTCGI Server\uff0c\u800cApache\u662fHTTP Server\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
CGI \u7684\u4f5c\u7528<\/strong><\/span><\/div>\n

CGI \u662f\u4e3a\u4e86\u4fdd\u8bc1 web server \u4f20\u9012\u8fc7\u6765\u7684\u6570\u636e\u662f\u6807\u51c6\u683c\u5f0f\u7684\uff0c\u65b9\u4fbf CGI \u7a0b\u5e8f\u7684\u7f16\u5199\u8005\u3002<\/p>\n

web server\uff08\u6bd4\u5982\u8bf4 nginx\uff09\u53ea\u662f\u5185\u5bb9\u7684\u5206\u53d1\u8005\u3002<\/p>\n

\u5982\u679c\u8bf7\u6c42 \/index.html\uff0c\u90a3\u4e48 web server \u4f1a\u53bb\u6587\u4ef6\u7cfb\u7edf\u4e2d\u627e\u5230\u8fd9\u4e2a\u6587\u4ef6\uff0c\u53d1\u9001\u7ed9\u6d4f\u89c8\u5668\uff0c\u8fd9\u91cc\u5206\u53d1\u7684\u662f\u9759\u6001\u6570\u636e\u3002<\/p>\n

\u5982\u679c\u73b0\u5728\u8bf7\u6c42\u7684\u662f \/index.php\uff0c\u6839\u636e\u914d\u7f6e\u6587\u4ef6\uff0cnginx \u77e5\u9053\u8fd9\u4e2a\u4e0d\u662f\u9759\u6001\u6587\u4ef6\uff0c\u9700\u8981\u53bb\u627e PHP \u89e3\u6790\u5668\u6765\u5904\u7406\uff0c\u90a3\u4e48\u4ed6\u4f1a\u628a\u8fd9\u4e2a\u8bf7\u6c42\u7b80\u5355\u5904\u7406\u540e\u4ea4\u7ed9 PHP \u89e3\u6790\u5668\u3002<\/p>\n

Nginx \u4f1a\u4f20\u54ea\u4e9b\u6570\u636e\u7ed9 PHP \u89e3\u6790\u5668\u5462\uff1furl\u3001\u67e5\u8be2\u5b57\u7b26\u4e32\u3001POST \u6570\u636e\u3001HTTP header \u7b49\u7b49\uff0cCGI \u5c31\u662f\u89c4\u5b9a\u8981\u4f20\u54ea\u4e9b\u6570\u636e\u3001\u4ee5\u4ec0\u4e48\u6837\u7684\u683c\u5f0f\u4f20\u9012\u7ed9\u540e\u65b9\u5904\u7406\u8fd9\u4e2a\u8bf7\u6c42\u7684\u534f\u8bae\u3002<\/p>\n

\u5f53 web server \u6536\u5230 \/index.php \u8fd9\u4e2a\u8bf7\u6c42\u540e\uff0c\u4f1a\u542f\u52a8\u5bf9\u5e94\u7684 CGI \u7a0b\u5e8f\uff0c\u8fd9\u91cc\u5c31\u662f PHP \u7684\u89e3\u6790\u5668\u3002\u63a5\u4e0b\u6765 PHP \u89e3\u6790\u5668\u4f1a\u89e3\u6790 php.ini \u6587\u4ef6\uff0c\u521d\u59cb\u5316\u6267\u884c\u73af\u5883\uff0c\u7136\u540e\u5904\u7406\u8bf7\u6c42\uff0c\u518d\u4ee5\u89c4\u5b9a CGI \u89c4\u5b9a\u7684\u683c\u5f0f\u8fd4\u56de\u5904\u7406\u540e\u7684\u7ed3\u679c\uff0c\u9000\u51fa\u8fdb\u7a0b\u3002<\/p>\n

web server \u518d\u628a\u7ed3\u679c\u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668\u3002 <\/p>\n

CGI \u662f\u4e2a\u534f\u8bae\uff0c\u8ddf\u8fdb\u7a0b\u4ec0\u4e48\u7684\u6ca1\u5173\u7cfb\u3002<\/p>\n

fastCgi \u662f\u4ec0\u4e48<\/strong><\/span><\/div>\n

fastCgi \u662f\u7528\u6765\u63d0\u9ad8 CGI \u7a0b\u5e8f\u6027\u80fd\u7684\u3002<\/p>\n

\u90a3\u4e48 CGI \u7a0b\u5e8f\u7684\u6027\u80fd\u95ee\u9898\u5728\u54ea\u5462\uff1f\u201dPHP \u89e3\u6790\u5668\u4f1a\u89e3\u6790 php.ini \u6587\u4ef6\uff0c\u521d\u59cb\u5316\u6267\u884c\u73af\u5883\u201d\uff0c\u5c31\u662f\u8fd9\u91cc\u4e86\u3002\u6807\u51c6\u7684 CGI \u5bf9\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u4f1a\u6267\u884c\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u6240\u4ee5\u5904\u7406\u6bcf\u4e2a\u8bf7\u6c42\u7684\u65f6\u95f4\u4f1a\u6bd4\u8f83\u957f\u3002<\/p>\n

\u90a3\u4e48 fastCgi \u662f\u600e\u4e48\u505a\u7684\u5462\uff1f\u9996\u5148\uff0cfastCgi \u4f1a\u5148\u542f\u4e00\u4e2a master\uff0c\u89e3\u6790\u914d\u7f6e\u6587\u4ef6\uff0c\u521d\u59cb\u5316\u6267\u884c\u73af\u5883\uff0c\u7136\u540e\u518d\u542f\u52a8\u591a\u4e2a worker\u3002\u5f53\u8bf7\u6c42\u8fc7\u6765\u65f6\uff0cmaster \u4f1a\u4f20\u9012\u7ed9\u4e00\u4e2a worker\uff0c\u7136\u540e\u7acb\u5373\u53ef\u4ee5\u63a5\u53d7\u4e0b\u4e00\u4e2a\u8bf7\u6c42\u3002\u8fd9\u6837\u5c31\u907f\u514d\u4e86\u91cd\u590d\u7684\u52b3\u52a8\uff0c\u6548\u7387\u81ea\u7136\u662f\u9ad8\u3002\u800c\u4e14\u5f53 worker \u4e0d\u591f\u7528\u65f6\uff0cmaster \u53ef\u4ee5\u6839\u636e\u914d\u7f6e\u9884\u5148\u542f\u52a8\u51e0\u4e2a worker \u7b49\u7740\uff1b\u5f53\u7136\u7a7a\u95f2 worker \u592a\u591a\u65f6\uff0c\u4e5f\u4f1a\u505c\u6389\u4e00\u4e9b\uff0c\u8fd9\u6837\u5c31\u63d0\u9ad8\u4e86\u6027\u80fd\uff0c\u4e5f\u8282\u7ea6\u4e86\u8d44\u6e90\u3002\u8fd9\u5c31\u662f fastCgi \u5bf9\u8fdb\u7a0b\u7684\u7ba1\u7406\u3002<\/p>\n

PHP-FPM \u662f\u4ec0\u4e48<\/strong><\/span><\/div>\n

PHP-FPM \u662f\u4e00\u4e2a\u5b9e\u73b0\u4e86 FastCgi \u7684\u7a0b\u5e8f\uff0c\u88ab PHP \u5b98\u65b9\u6536\u5f55\u3002<\/p>\n

PHP \u7684\u89e3\u91ca\u5668\u662f php-cgi\uff0c\u5b83\u53ea\u662f\u4e2a CGI \u7a0b\u5e8f\uff0c\u53ea\u80fd\u89e3\u6790\u8bf7\u6c42\uff0c\u8fd4\u56de\u7ed3\u679c\uff0c\u4e0d\u4f1a\u8fdb\u7a0b\u7ba1\u7406\u3002\u6240\u4ee5\u5c31\u51fa\u73b0\u4e86\u4e00\u4e9b\u80fd\u591f\u8c03\u5ea6 php-cgi \u8fdb\u7a0b\u7684\u7a0b\u5e8f\uff0c\u6bd4\u5982\u8bf4\u7531 lighthttpd \u5206\u79bb\u51fa\u6765\u7684 spawn-fcgi\u3002<\/p>\n

PHP-FPM \u4e5f\u662f\u8fd9\u4e48\u4e2a\u4e1c\u897f\uff0c\u5728\u957f\u65f6\u95f4\u7684\u53d1\u5c55\u540e\uff0c\u9010\u6e10\u5f97\u5230\u4e86\u5927\u5bb6\u7684\u8ba4\u53ef\uff0c\u4e5f\u8d8a\u6765\u8d8a\u6d41\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

CGI \u662f\u4e3a\u4e86\u4fdd\u8bc1 web server \u4f20\u9012\u8fc7\u6765\u7684\u6570\u636e\u662f\u6807\u51c6\u683c\u5f0f\u7684\uff0c\u65b9\u4fbf CGI \u7a0b\u5e8f\u7684\u7f16\u5199\u8005\u3002 web s […]<\/p>\n","protected":false},"author":1479,"featured_media":7797,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-139356","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/139356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=139356"}],"version-history":[{"count":10,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/139356\/revisions"}],"predecessor-version":[{"id":139458,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/139356\/revisions\/139458"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/7797"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=139356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=139356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=139356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}