{"id":51019,"date":"2024-10-08T15:28:19","date_gmt":"2024-10-08T07:28:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/51019\/"},"modified":"2024-10-08T15:28:19","modified_gmt":"2024-10-08T07:28:19","slug":"proxy_fcgierror-%e6%98%af%e4%bb%80%e9%ba%bc%ef%bc%9f%e5%a6%82%e4%bd%95%e8%a7%a3%e6%b1%ba%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/51019\/","title":{"rendered":"proxy_fcgi:error \u662f\u4ec0\u9ebc\uff1f\u5982\u4f55\u89e3\u6c7a\uff1f"},"content":{"rendered":"<h1 id=\"proxy_fcgierror-%e6%98%af%e4%bb%80%e9%ba%bc%ef%bc%9f%e5%a6%82%e4%bd%95%e8%a7%a3%e6%b1%ba%ef%bc%9f-bSLwbuCAYE\">proxy_fcgi:error \u662f\u4ec0\u9ebc\uff1f\u5982\u4f55\u89e3\u6c7a\uff1f<\/h1>\n<p>\u5728\u4f7f\u7528\u7db2\u9801\u4f3a\u670d\u5668\u6642\uff0c\u5c24\u5176\u662f\u642d\u914d PHP \u61c9\u7528\u7a0b\u5f0f\u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4e00\u500b\u932f\u8aa4\u8a0a\u606f\uff1a<code>proxy_fcgi:error<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8207 FastCGI \u7684\u914d\u7f6e\u6709\u95dc\uff0c\u7279\u5225\u662f\u5728\u4f7f\u7528 Nginx \u6216 Apache \u4f3a\u670d\u5668\u6642\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u6210\u56e0\u53ca\u5176\u89e3\u6c7a\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-proxy_fcgierror%ef%bc%9f-bSLwbuCAYE\">\u4ec0\u9ebc\u662f proxy_fcgi:error\uff1f<\/h2>\n<p>\u7576\u60a8\u5728\u4f3a\u670d\u5668\u4e0a\u904b\u884c PHP \u61c9\u7528\u7a0b\u5f0f\u6642\uff0cFastCGI \u662f\u4e00\u7a2e\u5e38\u7528\u7684\u5354\u8b70\uff0c\u7528\u65bc\u8655\u7406 PHP \u8acb\u6c42\u3002<code>proxy_fcgi:error<\/code> \u932f\u8aa4\u901a\u5e38\u8868\u793a\u4f3a\u670d\u5668\u5728\u5617\u8a66\u901a\u904e FastCGI \u4ee3\u7406\u8f49\u767c\u8acb\u6c42\u6642\u51fa\u73fe\u4e86\u554f\u984c\u3002\u9019\u53ef\u80fd\u662f\u7531\u65bc\u591a\u7a2e\u539f\u56e0\u9020\u6210\u7684\uff0c\u5305\u62ec\u914d\u7f6e\u932f\u8aa4\u3001\u4f3a\u670d\u5668\u904e\u8f09\u6216 PHP-FPM\uff08FastCGI Process Manager\uff09\u672a\u6b63\u78ba\u904b\u884c\u3002<\/p>\n<h2 id=\"proxy_fcgierror-%e7%9a%84%e5%b8%b8%e8%a6%8b%e5%8e%9f%e5%9b%a0-bSLwbuCAYE\">proxy_fcgi:error \u7684\u5e38\u898b\u539f\u56e0<\/h2>\n<ul>\n<li><strong>PHP-FPM \u672a\u555f\u52d5\uff1a<\/strong>\u5982\u679c PHP-FPM \u670d\u52d9\u672a\u904b\u884c\uff0c\u4f3a\u670d\u5668\u5c07\u7121\u6cd5\u8655\u7406 PHP \u8acb\u6c42\uff0c\u5f9e\u800c\u5c0e\u81f4\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u914d\u7f6e\u932f\u8aa4\uff1a<\/strong>\u5728 Nginx \u6216 Apache \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0cFastCGI \u7684\u8a2d\u7f6e\u53ef\u80fd\u4e0d\u6b63\u78ba\uff0c\u5c0e\u81f4\u8acb\u6c42\u7121\u6cd5\u6b63\u78ba\u8f49\u767c\u3002<\/li>\n<li><strong>\u8cc7\u6e90\u9650\u5236\uff1a<\/strong>\u4f3a\u670d\u5668\u7684\u8cc7\u6e90\uff08\u5982\u5167\u5b58\u6216 CPU\uff09\u4e0d\u8db3\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4 PHP-FPM \u7121\u6cd5\u8655\u7406\u8acb\u6c42\u3002<\/li>\n<li><strong>\u8d85\u6642\u8a2d\u5b9a\uff1a<\/strong>\u5982\u679c\u8acb\u6c42\u8655\u7406\u6642\u9593\u904e\u9577\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u8d85\u6642\u932f\u8aa4\uff0c\u5f9e\u800c\u5f15\u767c <code>proxy_fcgi:error<\/code>\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e8%a7%a3%e6%b1%ba-proxy_fcgierror%ef%bc%9f-bSLwbuCAYE\">\u5982\u4f55\u89e3\u6c7a proxy_fcgi:error\uff1f<\/h2>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5-php-fpm-%e7%8b%80%e6%85%8b-bSLwbuCAYE\">1. \u6aa2\u67e5 PHP-FPM \u72c0\u614b<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u4fdd PHP-FPM \u670d\u52d9\u6b63\u5728\u904b\u884c\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u5176\u72c0\u614b\uff1a<\/p>\n<pre><code>systemctl status php-fpm<\/code><\/pre>\n<p>\u5982\u679c\u670d\u52d9\u672a\u555f\u52d5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5\u5b83\uff1a<\/p>\n<pre><code>systemctl start php-fpm<\/code><\/pre>\n<h3 id=\"2-%e6%aa%a2%e6%9f%a5%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-bSLwbuCAYE\">2. \u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u6aa2\u67e5 Nginx \u6216 Apache \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u78ba\u4fdd FastCGI \u7684\u8a2d\u7f6e\u6b63\u78ba\u3002\u4ee5\u4e0b\u662f Nginx \u7684\u4e00\u500b\u7bc4\u4f8b\u914d\u7f6e\uff1a<\/p>\n<pre><code>location ~ .php$ {\n    include fastcgi_params;\n    fastcgi_pass 127.0.0.1:9000;  # \u78ba\u4fdd\u9019\u88e1\u7684\u5730\u5740\u548c\u7aef\u53e3\u6b63\u78ba\n    fastcgi_index index.php;\n    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n}<\/code><\/pre>\n<h3 id=\"3-%e8%aa%bf%e6%95%b4%e8%b3%87%e6%ba%90%e9%99%90%e5%88%b6-bSLwbuCAYE\">3. \u8abf\u6574\u8cc7\u6e90\u9650\u5236<\/h3>\n<p>\u5982\u679c\u4f3a\u670d\u5668\u8cc7\u6e90\u4e0d\u8db3\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5347\u7d1a\u60a8\u7684\u4f3a\u670d\u5668\u6216\u8abf\u6574 PHP-FPM \u7684\u914d\u7f6e\uff0c\u4ee5\u589e\u52a0\u53ef\u7528\u7684\u5de5\u4f5c\u9032\u7a0b\u6578\u91cf\u3002\u60a8\u53ef\u4ee5\u5728 PHP-FPM \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u5230\u76f8\u95dc\u8a2d\u7f6e\uff1a<\/p>\n<pre><code>pm.max_children = 5  # \u6839\u64da\u9700\u8981\u8abf\u6574\u6b64\u6578\u503c<\/code><\/pre>\n<h3 id=\"4-%e8%aa%bf%e6%95%b4%e8%b6%85%e6%99%82%e8%a8%ad%e5%ae%9a-bSLwbuCAYE\">4. \u8abf\u6574\u8d85\u6642\u8a2d\u5b9a<\/h3>\n<p>\u5982\u679c\u8acb\u6c42\u8655\u7406\u6642\u9593\u904e\u9577\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u589e\u52a0\u8d85\u6642\u8a2d\u5b9a\u3002\u5728 Nginx \u4e2d\uff0c\u60a8\u53ef\u4ee5\u9019\u6a23\u8a2d\u7f6e\uff1a<\/p>\n<pre><code>fastcgi_read_timeout 300;  # \u589e\u52a0\u8d85\u6642\u6642\u9593<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-bSLwbuCAYE\">\u7e3d\u7d50<\/h2>\n<p>\u9047\u5230 <code>proxy_fcgi:error<\/code> \u932f\u8aa4\u6642\uff0c\u9996\u5148\u8981\u6aa2\u67e5 PHP-FPM \u7684\u904b\u884c\u72c0\u614b\u53ca\u5176\u914d\u7f6e\uff0c\u7136\u5f8c\u6839\u64da\u9700\u8981\u8abf\u6574\u4f3a\u670d\u5668\u8cc7\u6e90\u548c\u8d85\u6642\u8a2d\u5b9a\u3002\u9019\u4e9b\u6b65\u9a5f\u80fd\u5e6b\u52a9\u60a8\u5feb\u901f\u5b9a\u4f4d\u554f\u984c\u4e26\u89e3\u6c7a\u5b83\u3002\u82e5\u60a8\u9700\u8981\u66f4\u7a69\u5b9a\u7684\u670d\u52d9\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u6216\u5176\u4ed6\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u4ee5\u78ba\u4fdd\u60a8\u7684\u7db2\u7ad9\u904b\u884c\u9806\u66a2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3 proxy_fcgi:error \u7684\u542b\u7fa9\u53ca\u5176\u89e3\u6c7a\u65b9\u6cd5\uff0c\u5e6b\u52a9\u60a8\u5feb\u901f\u6392\u9664\u7db2\u7ad9\u904b\u884c\u4e2d\u7684\u554f\u984c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-51019","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=51019"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51019\/revisions"}],"predecessor-version":[{"id":51020,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/51019\/revisions\/51020"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=51019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=51019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=51019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}