{"id":169271,"date":"2020-10-03T21:45:18","date_gmt":"2020-10-03T13:45:18","guid":{"rendered":"http:\/\/4563.org\/?p=169271"},"modified":"2020-10-03T21:45:18","modified_gmt":"2020-10-03T13:45:18","slug":"%e4%b8%8d%e6%87%82%e5%b0%b1%e9%97%ae%e7%b3%bb%e5%88%97%ef%bc%9a-php-%e7%bd%91%e7%ab%99%e4%bd%bf%e7%94%a8-nginx-%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%80%e4%ba%9b%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=169271","title":{"rendered":"\u4e0d\u61c2\u5c31\u95ee\u7cfb\u5217\uff1a PHP \u7f51\u7ad9\u4f7f\u7528 nginx \u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e0d\u61c2\u5c31\u95ee\u7cfb\u5217\uff1a PHP \u7f51\u7ad9\u4f7f\u7528 nginx \u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Ethson <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u51c6\u5907\u4f7f\u7528 php \u505a\u4e2a\u7f51\u7ad9\uff0c\u57df\u540d\u662f <code>dev.hellotools.org<\/code>\uff0c\u6839\u76ee\u5f55\u4e0b\u6709\u56db\u4e2a\u6587\u4ef6\uff0c\u5206\u522b\u662f\uff0c<\/p>\n<ol>\n<li><code>index.php<\/code>\uff0c\u5c31\u662f\u4e3b\u9875\u4e86<\/li>\n<li><code>about.php<\/code>\uff0c\u5173\u4e8e\u9875\u9762<\/li>\n<li><code>404.php<\/code>\uff0c\u4e5f\u5c31\u662f 404 \u9875\u9762\u4e86<\/li>\n<li><code>\/a\/b\/page.php<\/code>\uff0ca \u548c b \u662f\u76ee\u5f55\uff0c\u610f\u601d\u5c31\u662f\u6839\u76ee\u5f55\u4e0b\u6709\u4e2a\u4e8c\u7ea7\u76ee\u5f55\uff0c\u91cc\u8fb9\u6709\u4e2a <code>page.php<\/code><\/li>\n<\/ol>\n<p>\u73b0\u5728\u6211\u60f3\u5b9e\u73b0\u4ee5\u4e0b\u529f\u80fd\uff0c<\/p>\n<ol>\n<li>\u8bbf\u95ee <code>dev.hellotools.org<\/code> \u65f6\uff0c\u6d4f\u89c8\u5668\u4e0a\u5730\u5740\u680f\u663e\u793a <code>dev.hellotools.org<\/code>\uff0c\u4e14\u6d4f\u89c8\u5668\u663e\u793a <code>index.php<\/code> \u7684\u5185\u5bb9\uff1b<\/li>\n<li>\u8bbf\u95ee <code>dev.hellotools.org\/about<\/code> \u65f6\uff0c\u6d4f\u89c8\u5668\u4e0a\u5730\u5740\u680f\u663e\u793a <code>dev.hellotools.org\/about<\/code>\uff0c\u4e14\u6d4f\u89c8\u5668\u663e\u793a <code>about.php<\/code> \u7684\u5185\u5bb9\uff1b<\/li>\n<li>\u8bbf\u95ee <code>dev.hellotools.org\/nono<\/code> \u65f6\uff0c\u6d4f\u89c8\u5668\u4e0a\u5730\u5740\u680f\u663e\u793a <code>dev.hellotools.org\/nono<\/code>\uff0c\u4e14\u6d4f\u89c8\u5668\u663e\u793a <code>404.php<\/code> \u7684\u5185\u5bb9\uff1b<\/li>\n<li>\u8bbf\u95ee <code>dev.hellotools.org\/a\/b\/page<\/code> \u65f6\uff0c\u6d4f\u89c8\u5668\u4e0a\u5730\u5740\u680f\u663e\u793a <code>dev.hellotools.org\/a\/b\/page<\/code>\uff0c\u4e14\u6d4f\u89c8\u5668\u663e\u793a <code>\/a\/b\/page.php<\/code> \u7684\u5185\u5bb9<\/li>\n<\/ol>\n<p>\u4e8e\u662f\u6211\u7684 nginx \u914d\u7f6e\u5982\u4e0b\uff0c<\/p>\n<pre><code>server     {         listen 80;         server_name  dev.hellotools.org;          index index.html index.htm index.php default.html default.htm default.php;         root  \/home\/wwwroot\/dev.hellotools.org;          charset utf-8;          error_page 404 \/404.php;          ## enable php path info         location ~ [^\/].php(\/|$)         {             fastcgi_pass  unix:\/tmp\/php-cgi.sock;             fastcgi_index index.php;             include fastcgi.conf;             include pathinfo.conf;          }          location \/ {             try_files $uri $uri.php \/index.php;         }     } <\/code><\/pre>\n<p>\u641e\u4e0d\u6e05\u695a\u6211\u7684\u914d\u7f6e\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5728\u8bbf\u95ee <code>about<\/code> \u9875\u9762\u7684\u65f6\u5019\uff0c\u7adf\u7136\u6587\u4ef6\u76f4\u63a5\u4e0b\u8f7d\u4e86\uff0c404 \u4e5f\u51fa\u4e0d\u6765\uff0c\u4e0d\u77e5\u9053\u54ea\u91cc\u51fa\u95ee\u9898\u4e86\u3002<\/p>\n<p>\u6bcf\u4e2a\u9875\u9762\u7684\u5185\u5bb9\u90fd\u5199\u6e05\u695a\u4e86\uff0c\u5c31\u51e0\u4e2a\u7b80\u5355\u7684\u6c49\u5b57\u548c\u5b57\u6bcd\u3002\u6bd4\u5982\u4f60\u6253\u5f00\u7684\u662f <code>index.php<\/code>\uff0c\u90a3\u4e48\u9875\u9762\u5185\u5bb9\u5c31\u6709\uff1a<strong>index.php<\/strong>\u3002\u5176\u5b83\u90fd\u662f\u7c7b\u4f3c\u7684\u3002<\/p>\n<p>\u6298\u817e\u4e00\u665a\u4e0a\u4e86\uff0c\u5b9e\u5728\u627e\u4e0d\u51fa\u4e86\uff0c\u671b\u6709\u4e86\u89e3\u7684\u5927\u5144\u5f1f\u6307\u70b9\u4e00\u4e0b\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3811327\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dilu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`<br \/>try_files $uri $uri.php \/$url.php;<br \/>&#8220;`<\/p>\n<p>\u8bd5\u8bd5\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811328\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dilu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             try_files $uri $uri\/ \/$url.php;<\/p>\n<p>\u5982\u679c\u8fd8\u662f\u4e0d\u884c\u8bd5\u8bd5\u8fd9\u4e2a                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811329\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zjsxwc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ec5\u4ec5\u53ea\u662f\u53bb\u6389.php \u540e\u7f00\u7684\u8bdd<\/p>\n<p>&#8220;`<br \/>location \/ {<br \/> try_files $uri $uri.html $uri\/ @extensionless-php;<br \/> index index.html index.htm index.php;<br \/>}<br \/>location @extensionless-php {<br \/> rewrite ^(.*)$ $1.php last;<br \/>}<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811330\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Ethson <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dilu \u4f60\u7684\u7b2c\u4e8c\u4e2a\u7b54\u6848\u662f\u5bf9\u7684\u3002<\/p>\n<p>@zjsxwc \u4f60\u7684\u7b54\u6848\u4e5f\u662f\u5bf9\u7684\u3002<\/p>\n<p>\u975e\u5e38\u611f\u8c22\u4e24\u4f4d\u3002\u53ea\u662f @dilu \u63d0\u4f9b\u7684\u6b63\u786e\u7b54\u6848\u6709\u4e9b\u4e0d\u592a\u660e\u767d\uff0c\u4e3a\u4ec0\u4e48\u8981\u52a0\u4e0a **$uri\/**\uff0c\u8fd9\u4e0d\u662f\u5728\u76ee\u5f55\u4e0b\u67e5\u627e\u7684\u561b\uff0c\u4f46\u6211\u8fd9\u91cc\u6ca1\u6709\u8fd9\u4e2a\u76ee\u5f55\u554a\uff0c\u53bb\u627e\u4e5f\u6ca1\u7528\u554a\uff0c\u65e2\u7136\u662f\u65e0\u7528\u529f\uff0c\u90a3\u4e3a\u4ec0\u4e48\u53bb\u505a\u5462\uff1f\u4e0d\u5f97\u89e3&#8230;.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811331\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lax <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76f4\u63a5\u4e0b\u8f7d\u7684\u95ee\u9898\uff0c\u52a0\u4e00\u53e5 default_type text\/html;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811332\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Ethson <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lax \u8c22\u8c22\uff0c\u5b66\u5230\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811333\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : brader <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Ethson \u4f60\u7406\u89e3\u6709\u8bef\uff0c\u4f60\u4ed4\u7ec6\u7422\u78e8 try_files \u7684\u7528\u6cd5\uff0c\u5176\u5b9e\u6211\u60f3\uff0c$uri\/\u6ca1\u6709\u8d77\u4f5c\u7528\uff0c\u56e0\u4e3a\u5b83\u6b63\u5982\u4f60\u60f3\u7684\u4e00\u6837\uff0c\u6ca1\u627e\u5230\uff0c\u6240\u4ee5\u7ee7\u7eed\u6267\u884c\u540e\u9762\u4e00\u53e5\uff0c\u8d77\u4f5c\u7528\u7684\u662f\u540e\u9762\u4e00\u53e5 \/$url.php \uff0c<br \/>\u81f3\u4e8e\u4f60\u4e00\u5f00\u59cb\uff0c\u586b\u4e86$uri.php \uff0c\u95ee\u9898\u5c31\u5728\u8fd9\u91cc\u4e86\uff0cnginx \u627e\u5230\u4e86\u6539\u6587\u4ef6\uff0c\u6240\u4ee5 nginx \u7684 try_files \u4f1a\u5c06\u8be5\u6587\u4ef6\u53d1\u9001\u7ed9\u7528\u6237\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3811334\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Hanada <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Ethson \u4f18\u5148\u67e5\u627e\u662f\u5426\u5b58\u5728\u8be5\u8def\u5f84\uff0c\u4e0d\u5b58\u5728\u624d\u53bb\u627e.php \u6587\u4ef6\u3002\u4e5f\u5c31\u662f\u5982\u679c\u540c\u65f6\u6709\u4e00\u4e2a test \u6587\u4ef6\u5939\u548c test.php \uff0c\u4f1a\u4f18\u5148\u5339\u914d\u5230 test \u6587\u4ef6\u5939\u800c\u4e0d\u662f test.php                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0d\u61c2\u5c31\u95ee\u7cfb\u5217\uff1a PHP \u7f51\u7ad9\u4f7f\u7528 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/169271"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=169271"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/169271\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169271"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}