{"id":219,"date":"2022-02-20T16:22:30","date_gmt":"2022-02-20T08:22:30","guid":{"rendered":"https:\/\/blog.libra5.cool\/?p=219"},"modified":"2022-02-20T16:40:38","modified_gmt":"2022-02-20T08:40:38","slug":"%e5%bb%ba%e7%ab%99%e5%b0%8f%e8%ae%b04%ef%bc%9a%e5%88%a9%e7%94%a8wordpress%e5%bb%ba%e7%ab%99","status":"publish","type":"post","link":"https:\/\/blog.libra5.cool\/?p=219","title":{"rendered":"\u5efa\u7ad9\u5c0f\u8bb04\uff1a\u5229\u7528wordpress\u5efa\u7ad9"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u201c\u4eca\u5929\u6211\u4eec\u6765\u804a\u804a\u5982\u4f55\u4f7f\u7528wordpress\u8fdb\u884c\u5efa\u7ad9\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002\u201d<\/p><cite>\u6458\u8981<\/cite><\/blockquote>\n\n\n\n<p>\u524d\u9762\u6c34\u4e86\u8fd9\u4e48\u591a\uff0c\u4eca\u5929\u8ba9\u6211\u4eec\u6765\u770b\u770b\u5177\u4f53\u4f7f\u7528wordpress\u5982\u4f55\u5efa\u7ad9\uff0c\u7c97\u7565\u4ecb\u7ecd\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a1.\u5173\u4e8ehttps\u8bc1\u4e66\uff1b2.Nginx\u7b80\u5355\u914d\u7f6e\uff1b3.wordpress\u7684\u5b89\u88c5\u4e0e\u7b80\u5355\u914d\u7f6e\u3002<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-\u5173\u4e8ehttps\u8bc1\u4e66\">1.\u5173\u4e8ehttps\u8bc1\u4e66<\/h4>\n\n\n\n<p>https\u662f\u4e00\u79cd\u4f9d\u8d56\u8bc1\u4e66\u52a0\u5bc6\u7684\u5b89\u5168\u8fde\u63a5\u65b9\u5f0f\uff08\u6d4f\u89c8\u5668\u4e0a\u663e\u793a\u4e00\u4e2a\u5c0f\u9501\u6216\u8005\u5b89\u5168\u8fde\u63a5\uff09\uff0c\u4f7f\u7528https\u6211\u4eec\u9700\u8981\u5148\u83b7\u53d6\u57df\u540d\u76f8\u5173\u7684\u8bc1\u4e66\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u53ef\u4ee5\u4f7f\u7528\u514d\u8d39\u7684Let\u2019s Encrypt \u6765\u83b7\u53d6\u8bc1\u4e66\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>1.\u5b89\u88c5Nginx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install nginx<\/code><\/pre>\n\n\n\n<p>2.\u53c2\u7167\u5b98\u7f51\u6307\u5bfc\u6216\u81ea\u884c\u767e\u5ea6\u5b89\u88c5certbot<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;certbot.eff.org\/instructions<\/code><\/pre>\n\n\n\n<p>3.\u7533\u8bf7Let\u2019s Encrypt \u8bc1\u4e66<\/p>\n\n\n\n<p>\u6ce8\u610f\uff0c\u7533\u8bf7\u8bc1\u4e66\u9700\u8981\u5360\u7528http\u7aef\u53e3\uff0c\u6211\u4eec\u9700\u8981\u5148\u505c\u7528nginx\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service nginx stop<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528certbot\u7533\u8bf7\u8bc1\u4e66<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot --nginx<\/code><\/pre>\n\n\n\n<p>\u6839\u636e\u63d0\u793a\u8f93\u5165\u9700\u8981\u7533\u8bf7\u8bc1\u4e66\u7684\u57df\u540d\uff0c\u5982www.xxxx.com<\/p>\n\n\n\n<p>\u7b49\u5f85\u5b8c\u6210\u540e\u6211\u4eec\u5373\u83b7\u53d6\u4e86\u8bc1\u4e66\u6587\u4ef6\uff08\u6bcf\u4e2a\u57df\u540d\u6211\u4eec\u5c06\u5f97\u5230fullchain.pem\u548cprivkey.pem\u4e24\u4e2a\u6587\u4ef6\uff09\uff0c\u5e76\u4e14\u81ea\u52a8\u914d\u7f6e\u597dnginx\u6587\u4ef6\u3002\u5f53\u7136\u4e3a\u4e86\u4ee5\u9632\u4e07\u4e00\u6211\u4eec\u53ef\u4ee5\u67e5\u770bnginx\u914d\u7f6e\u6587\u4ef6\u6216\u8005\u81ea\u52a8\u914d\u7f6e\u4e0d\u6210\u529f\u65f6\u624b\u52a8\u7f16\u8f91\u8be5\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u7531\u4e8e\u8bc1\u4e66\u662f\u6709\u65f6\u6548\u6027\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b9a\u65f6\u4efb\u52a1\u53bbrenew\u8bc1\u4e66\uff0c\u5982crontab\uff0c\u5177\u4f53\u914d\u7f6e\u53ef\u4ee5\u81ea\u884c\u767e\u5ea6\u3002<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-nginx\u7b80\u5355\u914d\u7f6e\">2.Nginx\u7b80\u5355\u914d\u7f6e<\/h4>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770b\u4e00\u4e2a\u7b80\u5355\u5178\u578bnginx\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u54ea\u4e9b\u57fa\u672c\u4fe1\u606f\u4ee5\u53ca\u5b83\u4eec\u7684\u542b\u4e49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 443 ssl; #\u76d1\u542c443\u7aef\u53e3\n    server_name www.xxxxx.com; #\u8fd9\u91cc\u662f\u6211\u4eec\u7684\u57df\u540d\u5982www.xxxxx.com\n    ssl_certificate \/xxxxxx\/fullchain.pem; #\u8fd9\u91cc\u662f\u5bf9\u5e94\u57df\u540d\u7684fullchain.pem\u6587\u4ef6\u76ee\u5f55\n    ssl_certificate_key \/xxxx\/privkey.pem; #\u8fd9\u91cc\u662f\u5bf9\u5e94\u57df\u540d\u7684privkey.pem\u6587\u4ef6\u76ee\u5f55\n\n\n   location \/ {\n            root   \/xxxxx\/wordpress\/; #wordpress\u76ee\u5f55\n            index  index.php index.html index.htm;\n\t\t}\n\t\t\n    location ~* \\.php$ {\n    root            \/xxxxx\/wordpress\/; #wordpress\u76ee\u5f55\uff0c\u8fd9\u4e00\u6574\u5757\u533a\u57df\u4e3b\u8981\u914d\u7f6ephp\u89e3\u6790\u76f8\u5173\u5185\u5bb9\n    fastcgi_index   index.php;\n    fastcgi_pass    127.0.0.1:\u7aef\u53e3;\n    include         fastcgi_params;\n    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;\n}\n\t\n}<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e00\u4e2a\u975e\u5e38\u57fa\u672c\u7684nginx\u914d\u7f6e\uff0c\u4e3b\u8981\u7ed3\u6784\u4e0a\u6765\u8bf4\u5148\u662f\u786e\u5b9a\u9700\u8981\u76d1\u542c\u7684\u7aef\u53e3\u548c\u57df\u540d\uff0c\u7136\u540e\u914d\u7f6ehttps\u8bc1\u4e66\u6240\u5728\u4f4d\u7f6e\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u7ad9\u70b9\u7684index\u6587\u4ef6\u4f4d\u7f6e\u4e0ephp\u76f8\u5173\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u5982\u679c\u6211\u4eec\u8fd8\u6ca1\u6709\u5b89\u88c5php\u6216wordpress\uff0c\u4ee5\u4e0a\u90e8\u5206\u5185\u5bb9\u4f1a\u7f3a\u5931\u3002<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3-wordpress\u7684\u5b89\u88c5\u4e0e\u7b80\u5355\u914d\u7f6e\">3.wordpress\u7684\u5b89\u88c5\u4e0e\u7b80\u5355\u914d\u7f6e<\/h4>\n\n\n\n<p>wordpress\u4f9d\u8d56\u4e8ephp\u4e0e\u6570\u636e\u5e93\uff0c\u6240\u4ee5\u6211\u4eec\u8fd8\u9700\u5b89\u88c5\u8fd9\u4e24\u8005\u3002<\/p>\n\n\n\n<p>\u5b89\u88c5\u6570\u636e\u5e93\uff0c\u5982mariadb<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install mariadb-server<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php7.4 php7.4-fpm<\/code><\/pre>\n\n\n\n<p>\u4e0b\u8f7dwordpress<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget http:\/\/wordpress.org\/latest.tar.gz<\/code><\/pre>\n\n\n\n<p>\u89e3\u538bwordpress\u5305\uff0c\u89e3\u538b\u4f4d\u7f6e\u8bb0\u5f97\u66f4\u65b0nginx\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u5bf9\u5e94\u4f4d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -zxvf latest.tar.gz<\/code><\/pre>\n\n\n\n<p>\u767b\u9646db\u5e76\u521b\u5efawordpress\u6570\u636e\u5e93<\/p>\n\n\n\n<p>\u4fee\u6539wp-config-sample.php\u5e76\u4fdd\u5b58\u4e3awp-config.php\uff0c\u4fee\u6539\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define('DB_NAME', 'wordpress');\ndefine('DB_USER', '\u4f60\u7684\u6570\u636e\u5e93\u7528\u6237\u540d');\ndefine('DB_PASSWORD', ' your password');<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5PHP-mysql\u63d2\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install php-mysql<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6210\u540e\u6211\u4eec\u53ef\u4ee5\u56de\u5934\u67e5\u770bnginx\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0\u7f3a\u5931\u5185\u5bb9\uff0c\u5e76\u91cd\u542fnginx\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service nginx reload\nservice nginx restart<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u57df\u540d\u6216\u5728\u670d\u52a1\u5668\u672c\u5730\u8bbf\u95ee127.0.0.1\u6253\u5f00wordpress\u7684\u5b89\u88c5\u914d\u7f6e\u9875\u9762\u3002<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u914d\u7f6e\u5b8c\u6210\uff0cwordpress\u4f1a\u751f\u6210\u4e00\u7ec4\u5bc6\u7801\uff0c\u6211\u4eec\u901a\u8fc7\u5b89\u88c5\u65f6\u7684\u90ae\u7bb1\u548c\u8fd9\u4e2a\u5bc6\u7801\u5373\u53ef\u767b\u5f55wordpress\u5f00\u59cb\u771f\u6b63\u7684\u7f51\u7ad9\u5185\u5bb9\u5efa\u8bbe\u4e86\u3002<\/p>\n\n\n\n<p>\u6700\u540e\u8bf4\u51e0\u4e2a\u7ecf\u5e38\u4f1a\u7528\u5230\u7684\u5c0f\u5de5\u5177\u6216\u5c0f\u6280\u5de7\uff1a<\/p>\n\n\n\n<p>1.\u5220\u9664\u591a\u4f59\u7248\u672c<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7wordpress\u7684\u5404\u79cd\u63d2\u4ef6\u6765\u5b8c\u6210\u5bf9\u7f51\u7ad9\u7684\u5f88\u591a\u4f18\u5316\uff0c\u6bd4\u5982WP-Optimize\u3002<\/p>\n\n\n\n<p>2.\u5173\u4e8e\u5e95\u90e8\u7684\u201c\u7531wordpress\u9a71\u52a8\u201d<\/p>\n\n\n\n<p>\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91footer.php\u6765\u5b8c\u6210\uff0c\u65b9\u6cd5\u5927\u7ea6\u4e3a\u572827\u300128\u300129\u884c\u5404\u52a0\u4e0a\u201c \/\/ \u201d \u7136\u540e\u4fdd\u5b58\u66f4\u65b0\uff08\u5177\u4f53\u6ce8\u91ca\u6389\u7684\u5185\u5bb9\u8fd8\u8bf7\u81ea\u884c\u6838\u5bf9\uff0c\u53ef\u80fd\u4f1a\u56e0\u7248\u672c\u4e0d\u540c\u5bfc\u81f4\u884c\u6570\u4e0d\u4e00\u81f4\uff09\u3002<\/p>\n\n\n\n<p>3.\u6587\u7ae0\u5217\u8868\u4e0d\u60f3\u5c55\u793a\u5168\u6587<\/p>\n\n\n\n<p>\u7f16\u8f91index.php\u6587\u4ef6\uff0c\u627e\u5230\u7ea629\u884c\u6dfb\u52a0 ,&#8217;excerpt&#8217;\u53d8\u4e3a\uff1a<br>get_template_part( &#8216;template-parts\/content\/content&#8217;,&#8217;excerpt&#8217;);<br>\u5237\u65b0\u9875\u9762\u5373\u53ef\uff08\u5177\u4f53\u4fee\u6539\u7684\u5185\u5bb9\u8fd8\u8bf7\u81ea\u884c\u6838\u5bf9\uff0c\u53ef\u80fd\u4f1a\u56e0\u7248\u672c\u4e0d\u540c\u5bfc\u81f4\u884c\u6570\u4e0d\u4e00\u81f4\uff09\u3002<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>\u4ee5\u4e0a\uff0c\u5168\u6587\u7ed3\u675f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u201c\u4eca\u5929\u6211\u4eec\u6765\u804a\u804a\u5982\u4f55\u4f7f\u7528wordpress\u8fdb\u884c\u5efa\u7ad9\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002\u201d<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-web","entry"],"_links":{"self":[{"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=219"}],"version-history":[{"count":0,"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=\/wp\/v2\/posts\/219\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.libra5.cool\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}