{"id":849,"date":"2020-09-08T23:25:33","date_gmt":"2020-09-08T15:25:33","guid":{"rendered":"https:\/\/www.iotch.xyz\/?p=849"},"modified":"2020-09-08T23:25:33","modified_gmt":"2020-09-08T15:25:33","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e6%90%ad%e5%bb%ba%e4%b8%aa%e4%ba%ba%e5%8d%9a%e5%ae%a2%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%88nginxphpmysqltypecho%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.iotch.xyz\/?p=849","title":{"rendered":"\u6811\u8393\u6d3e\u642d\u5efa\u4e2a\u4eba\u535a\u5ba2\u670d\u52a1\u5668\uff08Nginx+PHP+mysql+typecho\uff09"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5efa\u8bae\u5728\u5b89\u88c5\u4e4b\u524d\u5148\u5b89\u88c5Pi Dashboard\uff08\u6211\u7684\u535a\u5ba2\u91cc\u6709\u8be6\u7ec6\u5b89\u88c5\u6559\u7a0b\uff09,\u901a\u8fc7\u70ab\u9177\u7684 WebUI \u6765\u76d1\u63a7\u6811\u8393\u6d3e\u7684\u72b6\u6001\uff01<br>\u5982\u679c\u5df2\u7ecf\u6309\u7167\u6559\u7a0b\u5b8c\u6210\u4e86Pi Dashboard\u7684\u5b89\u88c5\uff0c\u5373\u53ef\u8df3\u8fc7\u7b2c\u4e00\u6b65\uff08\u5b89\u88c5Nginx\u548cPHP\uff09<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5b89\u88c5Nginx\u548cPHP<\/h2>\n\n\n\n<p>\u5728 Pi \u7684\u7ec8\u7aef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    sudo apt-get update\n    sudo apt-get install nginx php7.3-fpm php7.3-cli php7.3-curl php7.3-gd php7.3-cgi\n    sudo service nginx start\n    sudo service php7.3-fpm restart\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u53ef\u901a\u8fc7 http:\/\/\u6811\u8393\u6d3eIP\/ \u8bbf\u95ee\u5230 Nginx \u7684\u9ed8\u8ba4\u9875\u3002Nginx \u7684\u6839\u76ee\u5f55\u5728 \/var\/www\/html\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u63a5\u4e0b\u6765\u8981\u8ba9Nginx\u80fd\u5904\u7406PHP<\/h4>\n\n\n\n<p><code>sudo nano \/etc\/nginx\/sites-available\/default<\/code><br>\u5c06\u5176\u4e2d\u7684\u5982\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location \/ {\n                # First attempt to serve request as file, then\n                # as directory, then fall back to displaying a 404.\n                try_files $uri $uri\/ =404;\n        }\n<\/code><\/pre>\n\n\n\n<p>\u66ff\u6362\u4e3a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location \/ {\n    index  index.html index.htm index.php default.html default.htm default.php;\n}\n \nlocation ~\\.php$ {\n    fastcgi_pass unix:\/run\/php\/php7.3-fpm.sock;\n    #fastcgi_pass 127.0.0.1:9000;\n    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n    include fastcgi_params;\n}\n<\/code><\/pre>\n\n\n\n<p>Ctrl + O \u4fdd\u56de\u8f66\u5b58\u518d Ctrl + X \u9000\u51fa\u3002<br>\u6700\u540e\u91cd\u542fNginx<br><code>sudo service nginx restart<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u5b89\u88c5mysql<\/h2>\n\n\n\n<p><code>sudo apt-get install mariadb-server<\/code><\/p>\n\n\n\n<p>\u4fee\u6539\u5bc6\u7801\uff1a<code>sudo mysqladmin -u root -p password<\/code><br>\u521d\u59cb\u5bc6\u7801\u968f\u4fbf\u8f93\u5165\uff0c\u7136\u540e\u8f93\u5165\u60a8\u7684\u5bc6\u7801\uff0c\u5373\u53ef\u8bbe\u7f6eroot\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n\n\n\n<p>\u8fdb\u5165\u6570\u636e\u5e93\uff1a<code>sudo mysql -u root -p<\/code>\uff0c\u7136\u540e\u8f93\u5165\u60a8\u8bbe\u7f6e\u7684\u5bc6\u7801\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528Typecho\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>typecho<\/code>\u7684\u6570\u636e\u5e93\uff1a<br><code>CREATE DATABASE typecho;<\/code><\/p>\n\n\n\n<p>\u628a\u6570\u636e\u53ef\u6743\u9650\u4ea4\u7ed9root\u7528\u6237\uff1a<br><code>GRANT ALL PRIVILEGES ON typecho.* TO 'root'@'localhost' IDENTIFIED BY '\u60a8\u8bbe\u7f6e\u7684\u5bc6\u7801';<\/code><br><code>FLUSH PRIVILEGES;<\/code><br>\u7136\u540e\u6309 Ctrl+D \u9000\u51fa MariaDB \u63d0\u793a\u7b26\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5b89\u88c5Typecho<\/h2>\n\n\n\n<p>\u5728Typecho\u5b98\u7f51\u4e0b\u8f7dTypecho\uff0c\u89e3\u538b\u540e\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u6307\u5b9a\u76ee\u5f55\uff08\u6811\u8393\u6d3e\u9ed8\u8ba4\u4e3a<code>\/var\/www\/html<\/code>\uff09<br>\u4e0a\u4f20\u5b8c\u6bd5\uff0c\u8bbf\u95ee http:\/\/\u6811\u8393\u6d3eIP\/ \u5373\u53ef\u770b\u5230Typecho\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6839\u636e\u5f15\u5bfc\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5b98\u7f51\u5b89\u88c5\u6587\u6863\uff1ahttp:\/\/docs.typecho.org\/install<\/p><\/blockquote>\n\n\n\n<p>\u8fdb\u5165Typecho\u540e\u3001\u65e0\u6cd5\u767b\u5f55\u540e\u53f0\uff0c\u70b9\u51fb\u524d\u53f0\u94fe\u63a5\u6216\u8005\u540e\u53f0\u767b\u5f55\u65f6\u51fa\u73b0\"404, not found\"<\/p>\n\n\n\n<p>\u8fd9\u662fnginx\u7684\u8bbe\u7f6e\u65f6\u6ca1\u6709\u6ce8\u610f\u652f\u6301pathinfo\u5bfc\u81f4\u7684\uff0c\u5177\u4f53\u5173\u4e8ephp pathinfo\u7684\u4fe1\u606f\u53ef\u4ee5\u5728\u7f51\u4e0a\u641c\u7d22\u5230\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u89e3\u51b3\u65b9\u6cd5<\/h4>\n\n\n\n<p>\u6253\u5f00Nginx\u7684\u914d\u7f6e\u6587\u4ef6<code>sudo nano \/etc\/nginx\/sites-available\/default<\/code>,\u4e00\u822c\u7684\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u65f6,location\u8bbe\u7f6e\u90fd\u662f\u7c7b\u4f3c\u8fd9\u6837<br><code>location ~ .*\\.php$<\/code><br>\u8981\u652f\u6301pathinfo\uff0c\u8981\u6539\u6210<br><code>location ~ .*\\.php(\\\/.*)*$<\/code><br>\u7136\u540e\u5728location\u91cc\u52a0\u4e0a<br>\uff08\u6ce8\u610f\u662f\u52a0\u4e0a\u4e0d\u662f\u66ff\u6362\uff01\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>            set $path_info \"\";\n            set $real_script_name $fastcgi_script_name;\n            if ($fastcgi_script_name ~ \"^(.+?\\.php)(\/.+)$\") {\n                    set $real_script_name $1;\n                    set $path_info $2;\n            }\n            fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;\n            fastcgi_param SCRIPT_NAME $real_script_name;\n            fastcgi_param PATH_INFO $path_info;\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5176\u4ed6\u95ee\u9898\u53ef\u53c2\u8003\u5b98\u7f51\u6587\u6863 http:\/\/docs.typecho.org\/servers<\/p><\/blockquote>\n\n\n\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/www.it610.com\/article\/1296019845783035904.htm\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >https:\/\/www.it610.com\/article\/1296019845783035904.htm<\/a><\/p>\n<button class=\"simplefavorite-button\" data-postid=\"849\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>\u5efa\u8bae\u5728\u5b89\u88c5\u4e4b\u524d\u5148\u5b89\u88c5Pi Dashboard\uff08\u6211\u7684\u535a\u5ba2\u91cc\u6709\u8be6\u7ec6\u5b89\u88c5\u6559\u7a0b\uff09,\u901a\u8fc7\u70ab\u9177\u7684 WebUI \u6765\u76d1\u63a7\u6811\u8393\u6d3e\u7684\u72b6\u6001\uff01\u5982\u679c\u5df2\u7ecf\u6309\u7167 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-849","post","type-post","status-publish","format-standard","hentry","category-10"],"_links":{"self":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=849"}],"version-history":[{"count":0,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=\/wp\/v2\/posts\/849\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iotch.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}