{"id":580,"date":"2024-12-26T23:50:15","date_gmt":"2024-12-26T15:50:15","guid":{"rendered":"http:\/\/www.wengdao.net\/?p=580"},"modified":"2024-12-27T00:12:28","modified_gmt":"2024-12-26T16:12:28","slug":"php%e7%9a%84%e5%b8%b8%e8%a7%81%e7%9a%84%e8%bf%90%e8%a1%8c%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/jiandao.zliby.com\/?p=580","title":{"rendered":"PHP\u7684\u5e38\u89c1\u7684\u8fd0\u884c\u6a21\u5f0f"},"content":{"rendered":"<h3>PHP\u4e00\u5171\u5206\u4e3a\u4e94\u5927\u8fd0\u884c\u6a21\u5f0f\uff1a<\/h3>\n<ol>\n<li>CLI \u6a21\u5f0f\uff08Command Line Interface\uff09<\/li>\n<li>CGI \u6a21\u5f0f\uff08Common Gateway Interface\uff09<\/li>\n<li>FastCGI \u6a21\u5f0f<\/li>\n<li>Web\u6a21\u5757\u6a21\u5f0f\uff08Apache\u7b49Web\u670d\u52a1\u5668\u8fd0\u884c\u7684\u6a21\u5f0f\uff09<\/li>\n<li>ISAPI\uff08Internet Server Application Program Interface\uff09<\/li>\n<\/ol>\n<p>\u5907\u6ce8\uff1a\u5728 PHP5.3 \u4ee5\u540e\uff0cPHP \u4e0d\u518d\u6709 ISAPI \u6a21\u5f0f<\/p>\n<h4>1. CLI \u6a21\u5f0f\uff08Command Line Interface\uff09<\/h4>\n<h5>\u5de5\u4f5c\u539f\u7406<\/h5>\n<ul>\n<li>PHP \u4f5c\u4e3a\u547d\u4ee4\u884c\u5de5\u5177\u8fd0\u884c\uff0c\u65e0\u9700 Web \u670d\u52a1\u5668\u3002<\/li>\n<li>\u7528\u6237\u901a\u8fc7\u547d\u4ee4\u884c\u76f4\u63a5\u8c03\u7528 PHP \u89e3\u91ca\u5668\u6267\u884c\u811a\u672c\u3002<\/li>\n<li>\u73af\u5883\u53d8\u91cf\u5982 <code class=\"prettyprint\" >$_SERVER<\/code> \u4e0d\u53ef\u7528\uff0c\u4f46\u652f\u6301\u901a\u8fc7 <code>$argv<\/code> \u548c <code>$argc<\/code> \u4f20\u9012\u53c2\u6570\u3002<\/li>\n<\/ul>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u65e0\u9700 Web \u73af\u5883\uff0c\u8fd0\u884c\u7b80\u5355\u3002<\/li>\n<li>\u9002\u5408\u6279\u5904\u7406\u548c\u81ea\u52a8\u5316\u4efb\u52a1\uff0c\u6267\u884c\u6548\u7387\u9ad8\u3002<\/li>\n<li>\u811a\u672c\u53ef\u72ec\u7acb\u8fd0\u884c\uff0c\u6613\u4e8e\u8c03\u8bd5\u548c\u90e8\u7f72\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u4e0d\u652f\u6301 HTTP \u8bf7\u6c42\u5904\u7406\u3002<\/li>\n<li>\u9700\u624b\u52a8\u914d\u7f6e\u811a\u672c\u89e6\u53d1\u673a\u5236\uff08\u5982\u5b9a\u65f6\u4efb\u52a1\uff09\u3002<\/li>\n<li>\u5f00\u53d1\u8005\u9700\u8981\u719f\u6089\u547d\u4ee4\u884c\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<h5>\u5e94\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u5b9a\u65f6\u4efb\u52a1\uff08\u5982\u914d\u5408 <code class=\"prettyprint\" >crontab<\/code> \u6267\u884c\uff09\u3002<\/li>\n<li>\u540e\u53f0\u6570\u636e\u5904\u7406\uff08\u5982\u5927\u6279\u91cf\u5bfc\u5165\/\u5bfc\u51fa\uff09\u3002<\/li>\n<li>\u4e00\u6b21\u6027\u4efb\u52a1\u6216\u811a\u672c\u8c03\u8bd5\uff08\u5982\u6570\u636e\u5e93\u6e05\u7406\u811a\u672c\uff09\u3002<\/li>\n<\/ul>\n<h4>2. CGI \u6a21\u5f0f\uff08Common Gateway Interface\uff09<\/h4>\n<h5>\u5de5\u4f5c\u539f\u7406<\/h5>\n<ul>\n<li>\u6bcf\u4e2a HTTP \u8bf7\u6c42\u90fd\u4f1a\u542f\u52a8\u4e00\u4e2a\u72ec\u7acb\u7684 PHP \u8fdb\u7a0b\uff0c\u5904\u7406\u8bf7\u6c42\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/li>\n<li>Web \u670d\u52a1\u5668\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4f20\u9012\u8bf7\u6c42\u6570\u636e\uff0cPHP \u811a\u672c\u901a\u8fc7\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u5b8c\u6210\u6570\u636e\u4ea4\u6362\u3002<\/li>\n<\/ul>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u4e0e Web \u670d\u52a1\u5668\u89e3\u8026\uff0c\u9002\u914d\u6027\u5f3a\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u670d\u52a1\u5668\u3002<\/li>\n<li>\u90e8\u7f72\u7b80\u5355\uff0c\u6613\u4e8e\u7406\u89e3\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u6bcf\u6b21\u8bf7\u6c42\u90fd\u9700\u542f\u52a8\u65b0\u7684\u8fdb\u7a0b\uff0c\u6027\u80fd\u8f83\u5dee\u3002<\/li>\n<li>\u5e76\u53d1\u5904\u7406\u80fd\u529b\u4f4e\uff0c\u8d44\u6e90\u5f00\u9500\u5927\u3002<\/li>\n<li>\u5df2\u9010\u6e10\u88ab FastCGI \u66ff\u4ee3\u3002<\/li>\n<\/ul>\n<h5>\u5e94\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u65e9\u671f\u5c0f\u578b\u52a8\u6001\u7f51\u7ad9\u3002<\/li>\n<li>\u7279\u6b8a\u573a\u666f\u4e0b\u9700\u8981\u4f7f\u7528 CGI \u7684\u9057\u7559\u7cfb\u7edf\u3002<\/li>\n<\/ul>\n<h4>3. FastCGI \u6a21\u5f0f<\/h4>\n<h5>\u5de5\u4f5c\u539f\u7406<\/h5>\n<ul>\n<li>\u901a\u8fc7\u5e38\u9a7b\u8fdb\u7a0b\u6c60\uff08\u5982 PHP-FPM\uff09\u5904\u7406 HTTP \u8bf7\u6c42\uff0c\u907f\u514d\u6bcf\u6b21\u542f\u52a8\u65b0\u8fdb\u7a0b\u3002<\/li>\n<li>Web \u670d\u52a1\u5668\uff08\u5982 Nginx \u6216 Apache\uff09\u901a\u8fc7 FastCGI \u534f\u8bae\u4e0e PHP \u8fdb\u7a0b\u901a\u4fe1\uff0c\u5904\u7406\u7ed3\u679c\u901a\u8fc7 Web \u670d\u52a1\u5668\u8fd4\u56de\u7528\u6237\u3002<\/li>\n<\/ul>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u6027\u80fd\u9ad8\uff0c\u652f\u6301\u5e76\u53d1\uff0c\u9002\u7528\u4e8e\u9ad8\u6d41\u91cf\u573a\u666f\u3002<\/li>\n<li>\u8d44\u6e90\u5229\u7528\u7387\u9ad8\uff0c\u53ef\u901a\u8fc7\u914d\u7f6e\u4f18\u5316\u8fdb\u7a0b\u6c60\u3002<\/li>\n<li>\u4e0e Web \u670d\u52a1\u5668\u89e3\u8026\uff0c\u652f\u6301\u591a\u79cd\u670d\u52a1\u5668\uff08\u5982 Nginx\u3001Apache\uff09\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u914d\u7f6e\u8f83\u590d\u6742\uff08\u9700\u8981 PHP-FPM \u7b49\u5de5\u5177\uff09\u3002<\/li>\n<li>\u5360\u7528\u5185\u5b58\u8f83\u591a\uff08\u7528\u4e8e\u5e38\u9a7b\u8fdb\u7a0b\u6c60\uff09\u3002<\/li>\n<li>\u8c03\u8bd5\u590d\u6742\u5ea6\u9ad8\u4e8e CLI \u548c\u6a21\u5757\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<h5>\u5e94\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u9ad8\u5e76\u53d1\u7f51\u7ad9\uff08\u5982\u7535\u5546\u3001\u95e8\u6237\u7f51\u7ad9\uff09\u3002<\/li>\n<li>API \u670d\u52a1\u3001\u5fae\u670d\u52a1\u67b6\u6784\u3002<\/li>\n<li>\u5e38\u89c1\u67b6\u6784\uff1a<strong>Nginx + PHP-FPM<\/strong>\u3002<\/li>\n<\/ul>\n<h4>4. Web\u6a21\u5757\u6a21\u5f0f\uff08Apache \u6a21\u5757\u6a21\u5f0f\uff0c\u5982 mod_php\uff09<\/h4>\n<h5>\u5de5\u4f5c\u539f\u7406<\/h5>\n<ul>\n<li>PHP \u4f5c\u4e3a Web \u670d\u52a1\u5668\uff08\u5982 Apache\uff09\u7684\u6a21\u5757\u5d4c\u5165\u8fd0\u884c\u3002<\/li>\n<li>Web \u670d\u52a1\u5668\u7ebf\u7a0b\u76f4\u63a5\u8c03\u7528 PHP \u6a21\u5757\u89e3\u6790\u811a\u672c\uff0c\u5b8c\u6210\u8bf7\u6c42\u5904\u7406\u3002<\/li>\n<\/ul>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u914d\u7f6e\u7b80\u5355\uff0c\u4e0e Apache \u6df1\u5ea6\u96c6\u6210\u3002<\/li>\n<li>\u6027\u80fd\u4f18\u4e8e CGI\uff0c\u65e0\u9700\u6bcf\u6b21\u542f\u52a8\u65b0\u8fdb\u7a0b\u3002<\/li>\n<li>\u5bf9\u5c0f\u578b\u9879\u76ee\u53cb\u597d\uff0c\u90e8\u7f72\u6210\u672c\u4f4e\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u4e0e Web \u670d\u52a1\u5668\u5f3a\u8026\u5408\uff0c\u7075\u6d3b\u6027\u5dee\u3002<\/li>\n<li>\u5360\u7528\u8d44\u6e90\u8f83\u591a\uff0c\u4e0d\u9002\u5408\u9ad8\u5e76\u53d1\u3002<\/li>\n<li>\u90e8\u7f72\u6269\u5c55\u6027\u4e0d\u5982 FastCGI\u3002<\/li>\n<\/ul>\n<h5>\u5e94\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u5c0f\u578b\u6216\u4e2d\u578b\u7f51\u7ad9\u3002<\/li>\n<li>Apache \u4e3a\u4e3b\u7684\u4f20\u7edf\u67b6\u6784\u3002<\/li>\n<li>\u5f00\u53d1\u73af\u5883\u5feb\u901f\u90e8\u7f72\u3002<\/li>\n<\/ul>\n<h4>5. ISAPI \u6a21\u5f0f\uff08Internet Server Application Program Interface\uff09<\/h4>\n<h5>\u5de5\u4f5c\u539f\u7406<\/h5>\n<ul>\n<li>PHP \u88ab\u5b9e\u73b0\u4e3a ISAPI \u6269\u5c55\uff08\u52a8\u6001\u94fe\u63a5\u5e93\uff09\uff0c\u76f4\u63a5\u5d4c\u5165 Windows IIS \u670d\u52a1\u5668\u3002<\/li>\n<li>IIS \u63a5\u6536\u8bf7\u6c42\u540e\u8c03\u7528 PHP \u7684 ISAPI \u63a5\u53e3\u5b8c\u6210\u811a\u672c\u5904\u7406\uff0c\u7ed3\u679c\u8fd4\u56de\u7ed9 IIS\u3002<\/li>\n<\/ul>\n<h5>\u4f18\u70b9<\/h5>\n<ul>\n<li>\u9ad8\u6027\u80fd\uff0c\u4e0e IIS \u7d27\u5bc6\u96c6\u6210\u3002<\/li>\n<li>\u8bf7\u6c42\u65e0\u9700\u542f\u52a8\u989d\u5916\u8fdb\u7a0b\uff0c\u8d44\u6e90\u5229\u7528\u7387\u9ad8\u3002<\/li>\n<li>Windows \u5e73\u53f0\u8fd0\u884c\u53cb\u597d\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9<\/h5>\n<ul>\n<li>\u4ec5\u9002\u7528\u4e8e Windows \u548c IIS\uff0c\u5e73\u53f0\u9650\u5236\u8f83\u5927\u3002<\/li>\n<li>\u5f00\u53d1\u548c\u8c03\u8bd5\u590d\u6742\uff0c\u53ef\u79fb\u690d\u6027\u5dee\u3002<\/li>\n<li>\u968f FastCGI \u7684\u666e\u53ca\u9010\u6e10\u88ab\u66ff\u4ee3\u3002<\/li>\n<\/ul>\n<h5>\u5e94\u7528\u573a\u666f<\/h5>\n<ul>\n<li>\u4ee5 IIS \u4e3a\u57fa\u7840\u7684 Web \u5e94\u7528\u3002<\/li>\n<li>Windows \u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf\u3002<\/li>\n<li>\u7279\u5b9a\u7684\u9057\u7559 PHP \u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<h3>\u603b\u7ed3\u5bf9\u6bd4\u8868<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u6a21\u5f0f<\/th>\n<th><strong>\u5de5\u4f5c\u539f\u7406<\/strong><\/th>\n<th><strong>\u4f18\u70b9<\/strong><\/th>\n<th><strong>\u7f3a\u70b9<\/strong><\/th>\n<th><strong>\u5e94\u7528\u573a\u666f<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>CLI<\/strong><\/td>\n<td>\u547d\u4ee4\u884c\u8c03\u7528 PHP \u89e3\u91ca\u5668<\/td>\n<td>\u9ad8\u6548\u3001\u65e0\u9700 Web \u670d\u52a1\u5668\u652f\u6301<\/td>\n<td>\u65e0\u6cd5\u5904\u7406 HTTP \u8bf7\u6c42<\/td>\n<td>\u5b9a\u65f6\u4efb\u52a1\u3001\u540e\u53f0\u6570\u636e\u5904\u7406\u3001\u811a\u672c\u8c03\u8bd5<\/td>\n<\/tr>\n<tr>\n<td><strong>CGI<\/strong><\/td>\n<td>\u6bcf\u8bf7\u6c42\u542f\u52a8\u72ec\u7acb PHP \u8fdb\u7a0b<\/td>\n<td>\u7b80\u5355\uff0c\u4e0e\u670d\u52a1\u5668\u89e3\u8026<\/td>\n<td>\u6027\u80fd\u4f4e\uff0c\u8d44\u6e90\u5f00\u9500\u5927<\/td>\n<td>\u5c0f\u578b\u52a8\u6001\u7f51\u7ad9\u3001\u9057\u7559\u7cfb\u7edf<\/td>\n<\/tr>\n<tr>\n<td><strong>FastCGI<\/strong><\/td>\n<td>\u4f7f\u7528\u5e38\u9a7b\u8fdb\u7a0b\u6c60\u5904\u7406 HTTP \u8bf7\u6c42<\/td>\n<td>\u6027\u80fd\u9ad8\uff0c\u652f\u6301\u5e76\u53d1\uff0c\u7075\u6d3b\u6027\u597d<\/td>\n<td>\u914d\u7f6e\u590d\u6742\uff0c\u5360\u7528\u5185\u5b58<\/td>\n<td>\u9ad8\u5e76\u53d1\u7f51\u7ad9\u3001API \u670d\u52a1\u3001\u5fae\u670d\u52a1\u67b6\u6784<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6a21\u5757\u6a21\u5f0f<\/strong><\/td>\n<td>PHP \u5d4c\u5165 Web \u670d\u52a1\u5668\u7684\u7ebf\u7a0b<\/td>\n<td>\u914d\u7f6e\u7b80\u5355\uff0c\u90e8\u7f72\u65b9\u4fbf<\/td>\n<td>\u8026\u5408\u6027\u5f3a\uff0c\u8d44\u6e90\u5360\u7528\u8f83\u9ad8<\/td>\n<td>\u5c0f\u578b\u7f51\u7ad9\uff0c\u4f20\u7edf Apache \u67b6\u6784<\/td>\n<\/tr>\n<tr>\n<td><strong>ISAPI<\/strong><\/td>\n<td>IIS \u8c03\u7528 PHP \u7684 ISAPI \u63a5\u53e3\uff08DLL\uff09<\/td>\n<td>\u9ad8\u6548\uff0c\u4e0e IIS \u96c6\u6210\u5ea6\u9ad8<\/td>\n<td>\u5e73\u53f0\u9650\u5236\u5927\uff0c\u79fb\u690d\u6027\u5dee<\/td>\n<td>IIS \u7cfb\u7edf\u3001Windows \u73af\u5883\u7684\u9057\u7559\u5e94\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u4e00\u5171\u5206\u4e3a\u4e94\u5927\u8fd0\u884c\u6a21\u5f0f\uff1a CLI \u6a21\u5f0f\uff08Command Line Interface\uff09 CGI \u6a21\u5f0f\uff08Co [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/580"}],"collection":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=580"}],"version-history":[{"count":4,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":584,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions\/584"}],"wp:attachment":[{"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiandao.zliby.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}