{"id":49052,"date":"2024-12-02T13:11:48","date_gmt":"2024-12-02T05:11:48","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49052\/"},"modified":"2024-12-02T13:11:48","modified_gmt":"2024-12-02T05:11:48","slug":"%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91php%e6%9c%8d%e5%8a%a1%e6%97%b6%e5%87%ba%e7%8e%b0502%e9%94%99%e8%af%af%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49052\/","title":{"rendered":"\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u300b<\/span>\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241108\/1731033028672d77c4eb4e0.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528nginx\u8fdb\u884cphp\u670d\u52a1\u8f6c\u53d1\u65f6\u9047\u5230502\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u95ee\u9898\u63cf\u8ff0\uff1a<\/p>\n<p>\u5728docker\u914d\u7f6e\u4e2d\uff0c\u5c06php\u670d\u52a1\u4e0enginx\u8fdb\u884c\u8f6c\u53d1\u65f6\uff0c\u51fa\u73b0\u4e86502\u9519\u8bef\uff0c\u63d0\u793a\u65e0\u6cd5\u8fde\u63a5\u5230\u4e0a\u6e38\u3002<\/p>\n<p>\u914d\u7f6e\u4fe1\u606f\uff1a<\/p>\n<p>docker\u914d\u7f6e\uff1a<\/p>\n<pre>version: '3.5'\nservices:\n  nginx:\n    image: nginx:alpine\n    # ...\n    volumes:\n      - .\/projects:\/workspace\n    ports: \n      - 80:80\n      - 443:443\n    links:\n      - php\n  \n  php:\n    image: itxiaoma\/php8swoole:1.2\n    # ...\n    volumes:\n      - .\/projects:\/workspace\n    ports:\n      - 8000:8000<\/pre>\n<p>nginx\u914d\u7f6e\uff1a<\/p>\n<pre>server {\n    # ...\n    \n    location @octane {\n        # ...\n        \n        proxy_pass http:\/\/php_swoole$suffix;\n    }\n}<\/pre>\n<p>\u9519\u8bef\u4fe1\u606f\uff1a<\/p>\n<pre>2021\/11\/19 09:52:49 [error] 21#21: *13 connect() failed (111: connection refused) while connecting to upstream, client: 172.28.0.1, server: management.test, request: \"get \/ http\/1.1\", upstream: \"http:\/\/172.28.0.2:8000\/?\", host: \"management.test\"<\/pre>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p>\u8be5\u9519\u8bef\u53ef\u80fd\u662f\u7531\u4e8ephp\u670d\u52a1\u53ea\u76d1\u542clocalhost\uff08127.0.0.1\uff09\u9020\u6210\u7684\u3002\u5728nginx\u914d\u7f6e\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5c06proxy_pass\u6307\u4ee4\u4e2d\u76ee\u6807url\u7684\u4e3b\u673a\u90e8\u5206\u89e3\u6790\u4e3a0.0.0.0\u6765\u534f\u8c03\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>\u6b63\u786e\u7684proxy_pass\u6307\u4ee4\uff1a<\/p>\n<pre>proxy_pass http:\/\/0.0.0.0:8000$suffix;<\/pre>\n<p>\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4fee\u6539php artisan octane:start\u547d\u4ee4\uff0c\u6307\u5b9a&#8211;host=0.0.0.0\u53c2\u6570\uff0c\u4ee5\u4f7fphp\u670d\u52a1\u4fa6\u542c\u6240\u6709\u4f20\u5165\u63a5\u53e3\uff1a<\/p>\n<pre>php artisan octane:start --host=0.0.0.0<\/pre>\n<p>\u901a\u8fc7\u5e94\u7528\u8fd9\u4e9b\u66f4\u6539\uff0cnginx\u5e94\u8be5\u80fd\u591f\u6210\u529f\u8f6c\u53d1\u8bf7\u6c42\u5230php\u670d\u52a1\uff0c\u800c\u4e0d\u4f1a\u51fa\u73b0502\u9519\u8bef\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f \u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\u300a\u4f7f\u7528Nginx\u8f6c\u53d1PHP\u670d\u52a1\u65f6\u51fa\u73b0502\u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u300b\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01 \u4f7f\u7528nginx\u8fdb\u884cphp\u670d\u52a1\u8f6c\u53d1\u65f6\u9047\u5230502\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5 \u95ee\u9898\u63cf\u8ff0\uff1a \u5728docker\u914d\u7f6e\u4e2d\uff0c\u5c06php\u670d\u52a1\u4e0enginx\u8fdb\u884c\u8f6c\u53d1\u65f6\uff0c\u51fa\u73b0\u4e86502\u9519\u8bef\uff0c\u63d0\u793a\u65e0\u6cd5\u8fde\u63a5\u5230\u4e0a\u6e38\u3002 \u914d\u7f6e\u4fe1\u606f\uff1a docker\u914d\u7f6e\uff1a version: &#8216;3.5&#8217; services: nginx: image: nginx:alpine # &#8230; volumes: &#8211; .\/projects:\/workspace ports: &#8211; 80:80 &#8211; 443:443 links: &#8211; php php: image: itxiaoma\/php8swoole:1.2 # &#8230; volumes: &#8211; .\/projects:\/workspace ports: &#8211; 8000:8000 nginx\u914d\u7f6e\uff1a server { # &#8230; location @octane { # &#8230; proxy_pass http:\/\/php_swoole$suffix; } } \u9519\u8bef\u4fe1\u606f\uff1a 2021\/11\/19 09:52:49 [error] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49052","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49052"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49052\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}