{"id":76,"date":"2020-10-30T08:01:16","date_gmt":"2020-10-30T08:01:16","guid":{"rendered":"http:\/\/robinluo.top\/?p=76"},"modified":"2020-11-01T03:38:03","modified_gmt":"2020-11-01T03:38:03","slug":"php%e7%ae%80%e4%bb%8b","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=76","title":{"rendered":"php\u7b80\u4ecb"},"content":{"rendered":"\n<p>&nbsp;&nbsp;&nbsp;&nbsp;php\u539f\u59cb\u4e3aPersonal Home Page\u7684\u7f29\u5199\uff0c\u5df2\u7ecf\u6b63\u5f0f\u66f4\u540d\u4e3a &#8220;PHP: Hypertext Preprocessor&#8221;\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;php\u4f9d\u8d56php\u8fd0\u884c\u5bb9\u5668\u5373php\u8fdb\u7a0b\uff0c\u901a\u8fc7\u8be5\u8fdb\u7a0b\u5bf9php\u6587\u4ef6\u8fdb\u884c\u8f93\u5165\u5904\u7406\uff0c\u5728 <strong><em>\u6807\u51c6\u8f93\u51fa\u6d41<\/em><\/strong> \u8fd4\u56de\u8f93\u51fa\u7ed3\u679c\u3002\u7279\u70b9\u8fd0\u884c\u7b80\u5355\uff0c\u65e0\u9700\u7f16\u8bd1\u3002\u5728web\u5bb9\u5668\u4e0b\uff0c\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2aphp\u8fdb\u7a0b\uff0c\u6240\u4ee5\u53ea\u9700\u628aphp\u6587\u4ef6\u66f4\u6539\u540e\uff0c\u7acb\u5373\u8bbf\u95ee\u8be5php\u6587\u4ef6\uff0c\u5373\u53ef\u770b\u89c1\u6700\u65b0\u7684\u66f4\u6539\uff08\u6bcf\u53d1\u9001\u4e00\u4e2a\u8bf7\u6c42\uff0c\u4ea7\u751f\u4e86\u65b0\u7684\u8fdb\u7a0b\u91cd\u65b0\u8bfb\u53d6\u6587\u4ef6\uff09\u3002\u8c03\u8bd5\u5341\u5206\u65b9\u4fbf\u3002<\/p>\n\n\n\n<p>  \u8fd0\u884cphp\u73af\u5883\u6709\u591a\u79cd\u65b9\u6cd5<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;1\uff1a\u901a\u8fc7php\u547d\u4ee4<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;php -f  &#8220;xxx.php&#8221;  \u901a\u8fc7\u6307\u5b9a\u9700\u8981\u52a0\u8f7dphp\u6587\u4ef6\uff0c\u5f00\u542fphp\u8fdb\u7a0b\uff0c\u5728\u63a7\u5236\u53f0\u6807\u51c6\u8f93\u51fa\u6d41\u770b\u5230\u8be5\u6587\u4ef6\u7684\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;php -s localhost:8080 (-t &#8220;\u9879\u76ee\u6587\u4ef6\u5939&#8221;) \u901a\u8fc7-t \u6307\u5b9aphp\u6587\u4ef6\u7684\u6587\u4ef6\u5939\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u8fdb\u7a0b\u6267\u884c\u6587\u4ef6\u5939\u76ee\u5f55\u3002\u6d4f\u89c8\u5668\u8bbf\u95eelocalhost:8080\u901a\u8fc7\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u8bbf\u95ee\u5bf9\u5e94\u7684\u6587\u4ef6\uff08\u9ed8\u8ba4\u4e3aindex.php\uff09\uff0c\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u770b\u5230\u5bf9\u5e94\u6587\u4ef6\u7684\u8f93\u51fa\u3002\u8fd9\u4e2a\u5c31\u662f\u628aphp\u8fdb\u7a0b\u7684\u8f93\u51fa\u6d41\u6253\u5728web\u5bb9\u5668\u7684\u8bf7\u6c42\u8f93\u51fa\u4e0a\uff0c\u6240\u4ee5\u80fd\u5728\u6d4f\u89c8\u5668\u770b\u5230\u8f93\u51fa<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;2\uff1a\u901a\u8fc7web\u5bb9\u5668\u8bbf\u95ee\u3002\u5176\u5b9e\u5c31\u662f\u901a\u8fc7web\u5bb9\u5668\u6267\u884c\u8bf7\u6c42\u8f93\u5165\u5230socket\u4e2d\uff08\u6587\u4ef6socket\u6216\u7aef\u53e3socket\u90fd\u53ef\uff09\u3002\u670d\u52a1\u5668\u5f00\u542fphp-fpm\u670d\u52a1\uff0c\u76d1\u542c\u5bf9\u5e94\u7684socket\u4f5c\u4e3a\u8fdb\u7a0b\u8f93\u5165\uff0c\u5c06php-fpm\u7684\u6807\u51c6\u8f93\u51fa\u6d41\u6253\u5728socket\u4e0a\u4f9bweb\u5bb9\u5668\u8bfb\u53d6\u3002web\u5bb9\u5668\u518d\u628asocket\u7684\u8bfb\u53d6\u7684\u5185\u5bb9\u4f5c\u4e3a\u8bf7\u6c42\u54cd\u5e94\u8fd4\u56de\u7ed9\u7528\u6237\u3002\uff08\u8fd9\u5c31\u662f\u6807\u51c6\u7684cgi\u505a\u6cd5\uff0c\u4ee5\u8fdb\u7a0b\u6807\u51c6\u8f93\u5165\u6d41\u63a5\u53d7\u8bf7\u6c42\uff0c\u6807\u51c6\u8f93\u51fa\u6d41\u4ea7\u751f\u54cd\u5e94\uff0c\u4e00\u4e2a\u8bf7\u6c42\u5c31\u662f\u4e00\u4e2a\u8fdb\u7a0b\uff09\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;nginx\u914d\u7f6e\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>location ~ .php$ { <br>      fastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; <br>      fastcgi_index index.php; <br>      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <br>      include fastcgi_params; <br>}<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;apache\u914d\u7f6e\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>LoadModule&nbsp;php7_module&nbsp;&#8220;${INSTALL_DIR}\/bin\/php\/php7.1.9\/php7apache2_4.dll&#8221;<br><br>&lt;IfModule&nbsp;php7_module&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex&nbsp;index.php&nbsp;index.php3&nbsp;<br>    AddType&nbsp;application\/x-httpd-php&nbsp;.php<br>&nbsp;&nbsp;&nbsp;&nbsp;AddType&nbsp;application\/x-httpd-php&nbsp;.php3<br>&lt;\/IfModule&gt;<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;php\u539f\u59cb\u4e3aPersonal Home Page\u7684\u7f29\u5199\uff0c\u5df2\u7ecf\u6b63\u5f0f\u66f4\u540d\u4e3a &#8220;PHP: Hypertext Preprocessor&#8221;\u3002 &nbsp;&nbsp;&nbsp;&nbsp;php\u4f9d\u8d56php\u8fd0\u884c\u5bb9\u5668\u5373php\u8fdb\u7a0b\uff0c\u901a\u8fc7\u8be5\u8fdb\u7a0b\u5bf9php\u6587\u4ef6\u8fdb\u884c\u8f93\u5165\u5904\u7406\uff0c\u5728 \u6807\u51c6\u8f93\u51fa\u6d41 \u8fd4\u56de\u8f93\u51fa\u7ed3\u679c\u3002\u7279\u70b9\u8fd0\u884c\u7b80\u5355\uff0c\u65e0\u9700\u7f16\u8bd1\u3002\u5728web\u5bb9\u5668\u4e0b\uff0c\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2aphp\u8fdb\u7a0b\uff0c\u6240\u4ee5\u53ea\u9700\u628aphp\u6587\u4ef6\u66f4\u6539\u540e\uff0c\u7acb\u5373\u8bbf\u95ee\u8be5php\u6587\u4ef6\uff0c\u5373\u53ef\u770b\u89c1\u6700\u65b0\u7684\u66f4\u6539\uff08\u6bcf\u53d1\u9001\u4e00\u4e2a\u8bf7\u6c42\uff0c\u4ea7\u751f\u4e86\u65b0\u7684\u8fdb\u7a0b\u91cd\u65b0\u8bfb\u53d6\u6587\u4ef6\uff09\u3002\u8c03\u8bd5\u5341\u5206\u65b9\u4fbf\u3002 \u8fd0\u884cphp\u73af\u5883\u6709\u591a\u79cd\u65b9\u6cd5 &nbsp;&nbsp;&nbsp;&nbsp;1\uff1a\u901a\u8fc7php\u547d\u4ee4 &nbsp;&nbsp;&nbsp;&nbsp;php -f &#8220;xxx.php&#8221; \u901a\u8fc7\u6307\u5b9a\u9700\u8981\u52a0\u8f7dphp\u6587\u4ef6\uff0c\u5f00\u542fphp\u8fdb\u7a0b\uff0c\u5728\u63a7\u5236\u53f0\u6807\u51c6\u8f93\u51fa\u6d41\u770b\u5230\u8be5\u6587\u4ef6\u7684\u8f93\u51fa\u3002 &nbsp;&nbsp;&nbsp;&nbsp;php -s localhost:8080 (-t &#8220;\u9879\u76ee\u6587\u4ef6\u5939&#8221;) \u901a\u8fc7-t \u6307\u5b9aphp\u6587\u4ef6\u7684\u6587\u4ef6\u5939\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u8fdb\u7a0b\u6267\u884c\u6587\u4ef6\u5939\u76ee\u5f55\u3002\u6d4f\u89c8\u5668\u8bbf\u95eelocalhost:8080\u901a\u8fc7\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u8bbf\u95ee\u5bf9\u5e94\u7684\u6587\u4ef6\uff08\u9ed8\u8ba4\u4e3aindex.php\uff09\uff0c\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u770b\u5230\u5bf9\u5e94\u6587\u4ef6\u7684\u8f93\u51fa\u3002\u8fd9\u4e2a\u5c31\u662f\u628aphp\u8fdb\u7a0b\u7684\u8f93\u51fa\u6d41\u6253\u5728web\u5bb9\u5668\u7684\u8bf7\u6c42\u8f93\u51fa\u4e0a\uff0c\u6240\u4ee5\u80fd\u5728\u6d4f\u89c8\u5668\u770b\u5230\u8f93\u51fa &nbsp;&nbsp;&nbsp;&nbsp;2\uff1a\u901a\u8fc7web\u5bb9\u5668\u8bbf\u95ee\u3002\u5176\u5b9e\u5c31\u662f\u901a\u8fc7web\u5bb9\u5668\u6267\u884c\u8bf7\u6c42\u8f93\u5165\u5230socket\u4e2d\uff08\u6587\u4ef6socket\u6216\u7aef\u53e3socket\u90fd\u53ef\uff09\u3002\u670d\u52a1\u5668\u5f00\u542fphp-fpm\u670d\u52a1\uff0c\u76d1\u542c\u5bf9\u5e94\u7684socket\u4f5c\u4e3a\u8fdb\u7a0b\u8f93\u5165\uff0c\u5c06php-fpm\u7684\u6807\u51c6\u8f93\u51fa\u6d41\u6253\u5728socket\u4e0a\u4f9bweb\u5bb9\u5668\u8bfb\u53d6\u3002web\u5bb9\u5668\u518d\u628asocket\u7684\u8bfb\u53d6\u7684\u5185\u5bb9\u4f5c\u4e3a\u8bf7\u6c42\u54cd\u5e94\u8fd4\u56de\u7ed9\u7528\u6237\u3002\uff08\u8fd9\u5c31\u662f\u6807\u51c6\u7684cgi\u505a\u6cd5\uff0c\u4ee5\u8fdb\u7a0b\u6807\u51c6\u8f93\u5165\u6d41\u63a5\u53d7\u8bf7\u6c42\uff0c\u6807\u51c6\u8f93\u51fa\u6d41\u4ea7\u751f\u54cd\u5e94\uff0c\u4e00\u4e2a\u8bf7\u6c42\u5c31\u662f\u4e00\u4e2a\u8fdb\u7a0b\uff09\u3002 &nbsp;&nbsp;&nbsp;&nbsp;nginx\u914d\u7f6e\uff1a location ~ .php$ { fastcgi_pass unix:\/run\/php\/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } &nbsp;&nbsp;&nbsp;&nbsp;apache\u914d\u7f6e\uff1a LoadModule&nbsp;php7_module&nbsp;&#8220;${INSTALL_DIR}\/bin\/php\/php7.1.9\/php7apache2_4.dll&#8221; &lt;IfModule&nbsp;php7_module&gt;&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex&nbsp;index.php&nbsp;index.php3&nbsp; AddType&nbsp;application\/x-httpd-php&nbsp;.php&nbsp;&nbsp;&nbsp;&nbsp;AddType&nbsp;application\/x-httpd-php&nbsp;.php3&lt;\/IfModule&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":6,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}