{"id":22326,"date":"2024-11-21T13:19:07","date_gmt":"2024-11-21T05:19:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22326\/"},"modified":"2024-11-21T13:19:07","modified_gmt":"2024-11-21T05:19:07","slug":"%e8%af%a6%e7%bb%86%e4%bb%8b%e7%bb%8dthinkphp%e7%9a%84%e5%ae%89%e8%a3%85%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22326\/","title":{"rendered":"\u8be6\u7ec6\u4ecb\u7ecdthinkphp\u7684\u5b89\u88c5\u6b65\u9aa4"},"content":{"rendered":"<p>thinkphp \u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684 php \u5f00\u53d1\u6846\u67b6\uff0c\u5177\u6709\u9ad8\u6548\u7387\u3001\u7075\u6d3b\u6027\u548c\u5b89\u5168\u6027\u7b49\u4f18\u70b9\u3002\u5b83\u7b80\u5355\u6613\u7528\uff0c\u9002\u5408\u5f00\u53d1\u5404\u79cd\u89c4\u6a21\u7684 web \u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd thinkphp \u7684\u5b89\u88c5\u6b65\u9aa4\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u4e0b\u8f7d\u5e76\u89e3\u538b thinkphp \u6846\u67b6<\/p>\n<p>\u4f60\u53ef\u4ee5\u5728 thinkphp \u5b98\u7f51\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 thinkphp \u6846\u67b6\uff0c\u5e76\u89e3\u538b\u5230\u4f60\u7684\u670d\u52a1\u5668\u4e2d\u3002\u4e5f\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528 git clone \u547d\u4ee4\u4ece GitHub \u4e0a\u4e0b\u8f7d\uff1a<\/p>\n<pre>$ git clone https:\/\/github.com\/top-think\/think.git<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6216\u8005\u4ece composer \u5b89\u88c5\uff1a<\/p>\n<pre>$ composer create-project topthink\/think=6.0.* your-project-name<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5728 Windows \u64cd\u4f5c\u7cfb\u7edf\u4e0b\uff0c\u4f60\u9700\u8981\u5c06 php.exe \u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u4e2d\u3002\u5728 Linux \u548c macOS \u7cfb\u7edf\u4e0b\uff0c\u4f60\u9700\u8981\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u6587\u4ef6\uff08\u5982 \/etc\/profile\u3001~\/.bash_profile\uff09\uff1a<\/p>\n<pre>export PATH=$PATH:\/path\/to\/php\/bin<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u521b\u5efa\u865a\u62df\u4e3b\u673a<\/p>\n<p>thinkphp \u4f7f\u7528\u865a\u62df\u4e3b\u673a\u6765\u5904\u7406\u8bf7\u6c42\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u4e3b\u673a\u5e76\u914d\u7f6e\u5b83\u7684\u8bbf\u95ee\u8def\u5f84\u4ee5\u53ca\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u3002\u5728 Apache \u670d\u52a1\u5668\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7f16\u8f91 \/etc\/httpd\/conf\/httpd.conf \u6587\u4ef6\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>&lt;VirtualHost *:80&gt;\n    ServerName your-app.local\n    DocumentRoot \/path\/to\/your\/app\/public\n    &lt;Directory \/path\/to\/your\/app\/public&gt;\n        AllowOverride All\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728 Nginx \u670d\u52a1\u5668\u4e2d\uff0c\u4f60\u53ef\u4ee5\u7f16\u8f91 \/etc\/nginx\/sites-available\/default \u6587\u4ef6\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>upstream backend {\n    server unix:\/\/\/var\/run\/php-fpm.sock;\n}\n\nserver {\n    listen 80;\n    server_name your-app.local;\n    root \/path\/to\/your\/app\/public;\n\n    location \/ {\n        index index.php;\n        try_files $uri \/index.php$is_args$args;\n    }\n\n    location ~ .php$ {\n        fastcgi_pass backend;\n        include fastcgi_params;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u8bbf\u95ee\u4f60\u7684\u865a\u62df\u4e3b\u673a\uff0c\u4f60\u4f1a\u770b\u5230 thinkphp \u7684\u6b22\u8fce\u9875\u9762\u3002\u4f60\u53ef\u4ee5\u5728\u63a7\u5236\u5668\u548c\u89c6\u56fe\u4e2d\u6dfb\u52a0\u4f60\u81ea\u5df1\u7684\u4ee3\u7801\uff0c\u91cd\u65b0\u52a0\u8f7d\u5e94\u7528\u7a0b\u5e8f\u5373\u53ef\u6d4b\u8bd5\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u5b89\u88c5\u548c\u914d\u7f6e thinkphp \u6709\u5f88\u591a\u79cd\u65b9\u6cd5\uff0c\u672c\u6587\u53ea\u63d0\u4f9b\u4e86\u4e00\u79cd\u5e38\u7528\u7684\u65b9\u5f0f\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u719f\u6089 thinkphp \u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u5305\u62ec\u63a7\u5236\u5668\u3001\u89c6\u56fe\u3001\u6a21\u578b\u7b49\u6982\u5ff5\uff0c\u624d\u80fd\u66f4\u597d\u5730\u4f7f\u7528\u5b83\u6765\u5f00\u53d1 Web \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8be6\u7ec6\u4ecb\u7ecdthinkphp\u7684\u5b89\u88c5\u6b65\u9aa4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>thinkphp \u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684 php \u5f00\u53d1\u6846\u67b6\uff0c\u5177\u6709\u9ad8\u6548\u7387\u3001\u7075\u6d3b\u6027\u548c\u5b89\u5168\u6027\u7b49\u4f18\u70b9\u3002\u5b83\u7b80\u5355\u6613\u7528\uff0c\u9002\u5408\u5f00\u53d1\u5404\u79cd\u89c4\u6a21\u7684 web \u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd thinkphp \u7684\u5b89\u88c5\u6b65\u9aa4\u3002 \u7b2c\u4e00\u6b65\uff1a\u4e0b\u8f7d\u5e76\u89e3\u538b thinkphp \u6846\u67b6 \u4f60\u53ef\u4ee5\u5728 thinkphp \u5b98\u7f51\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 thinkphp \u6846\u67b6\uff0c\u5e76\u89e3\u538b\u5230\u4f60\u7684\u670d\u52a1\u5668\u4e2d\u3002\u4e5f\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528 git clone \u547d\u4ee4\u4ece GitHub \u4e0a\u4e0b\u8f7d\uff1a $ git clone https:\/\/github.com\/top-think\/think.git \u767b\u5f55\u540e\u590d\u5236 \u6216\u8005\u4ece composer \u5b89\u88c5\uff1a $ composer create-project topthink\/think=6.0.* your-project-name \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e8c\u6b65\uff1a\u914d\u7f6e\u73af\u5883\u53d8\u91cf \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5728 Windows \u64cd\u4f5c\u7cfb\u7edf\u4e0b\uff0c\u4f60\u9700\u8981\u5c06 php.exe \u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u4e2d\u3002\u5728 Linux \u548c macOS \u7cfb\u7edf\u4e0b\uff0c\u4f60\u9700\u8981\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u6587\u4ef6\uff08\u5982 \/etc\/profile\u3001~\/.bash_profile\uff09\uff1a export PATH=$PATH:\/path\/to\/php\/bin \u767b\u5f55\u540e\u590d\u5236 \u7b2c\u4e09\u6b65\uff1a\u521b\u5efa\u865a\u62df\u4e3b\u673a thinkphp \u4f7f\u7528\u865a\u62df\u4e3b\u673a\u6765\u5904\u7406\u8bf7\u6c42\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u4e3b\u673a\u5e76\u914d\u7f6e\u5b83\u7684\u8bbf\u95ee\u8def\u5f84\u4ee5\u53ca\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u3002\u5728 [&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-22326","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22326","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=22326"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22326\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}