{"id":7,"date":"2026-02-18T10:08:51","date_gmt":"2026-02-18T02:08:51","guid":{"rendered":"https:\/\/blog.8912345.xyz\/?p=7"},"modified":"2026-02-18T10:13:21","modified_gmt":"2026-02-18T02:13:21","slug":"%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%ef%bc%9a%e5%91%bd%e4%bb%a4%e8%a1%8c%e9%83%a8%e7%bd%b2-wordpress-%e4%b8%8e-nginx-certbot-%e8%87%aa%e5%8a%a8-ssl-%e7%bb%ad%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/blog.8912345.xyz\/?p=7","title":{"rendered":"\u4ece\u96f6\u5f00\u59cb\uff1a\u547d\u4ee4\u884c\u90e8\u7f72 WordPress \u4e0e Nginx\/Certbot \u81ea\u52a8 SSL \u7eed\u671f"},"content":{"rendered":"\n<p><strong>\u6458\u8981<\/strong><\/p>\n\n\n\n<p>\u672c\u6587\u6863\u8be6\u7ec6\u8bb0\u5f55\u4e86\u5728 Linux \u73af\u5883\u4e0b\uff0c\u901a\u8fc7 <code>wp-cli<\/code> \u5feb\u901f\u90e8\u7f72 WordPress \u5b9e\u4f8b\uff0c\u5e76\u7ed3\u5408 Nginx \u4f5c\u4e3a Web \u670d\u52a1\u5668\uff0c\u914d\u7f6e <code>certbot<\/code> \u5b9e\u73b0\u57df\u540d SSL \u8bc1\u4e66\u7684\u81ea\u52a8\u83b7\u53d6\u4e0e\u7eed\u671f\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u73af\u5883\u51c6\u5907\u4e0e\u6838\u5fc3\u6587\u4ef6\u90e8\u7f72<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1.1 \u6570\u636e\u5e93\u51c6\u5907<\/h4>\n\n\n\n<p>\u5b8c\u6210\u6570\u636e\u5e93\u7684\u521b\u5efa\u3001\u7528\u6237\u6388\u6743\u548c\u6570\u636e\u5e93\u7684\u521b\u5efa\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.2 \u5b89\u88c5 WP-CLI<\/h4>\n\n\n\n<p>\u901a\u8fc7 Phar \u5305\u5b89\u88c5 WP-CLI \u4ee5\u5b9e\u73b0\u65e0\u5934\u90e8\u7f72\uff1a<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo curl -O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar\nsudo mv wp-cli.phar \/usr\/local\/bin\/wp\nsudo chmod +x \/usr\/local\/bin\/wp<\/code><\/pre>\n\n\n\n<p>1.3 \u90e8\u7f72 WordPress \u6838\u5fc3<\/p>\n\n\n\n<p>\u6211\u4eec\u5c06\u7f51\u7ad9\u6839\u76ee\u5f55\u5b9a\u5728 \/var\/www\/html\/blog\uff0c\u5e76\u786e\u4fdd\u6240\u6709\u6743\u5f52\u4e8e Web \u670d\u52a1\u5668\u7528\u6237 www-data\uff0c\u4ee5\u907f\u514d\u6743\u9650\u51b2\u7a81\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5047\u8bbe\u6570\u636e\u5e93\u540d\u4e3a wordpress_db\uff0c\u7528\u6237\u4e3a wp_user\uff0c\u4e3b\u673a\u4e3a localhost\nsudo mkdir -p \/var\/www\/html\/blog\nsudo chown -R www-data:www-data \/var\/www\/html\/blog\n\n# \u4e0b\u8f7d\u6838\u5fc3\u6587\u4ef6\uff08\u4e2d\u6587\u7248\uff09\nsudo -u www-data \/usr\/local\/bin\/wp core download --locale=zh_CN --path=\/var\/www\/html\/blog\n\n# \u521b\u5efa wp-config.php\nsudo -u www-data \/usr\/local\/bin\/wp config create --dbname=wordpress_db --dbuser=wp_user --dbpass='&lt;DB_PASSWORD_PLACEHOLDER&gt;' --locale=zh_CN --path=\/var\/www\/html\/blog\n\n# \u6838\u5fc3\u5b89\u88c5\nsudo -u www-data \/usr\/local\/bin\/wp core install --url='https:\/\/blog.8912345.xyz' --title='\u6211\u7684\u535a\u5ba2' --admin_user='admin_user' --admin_password='&lt;ADMIN_PASSWORD_PLACEHOLDER&gt;' --admin_email='admin@example.com' --skip-email --path=\/var\/www\/html\/blog<\/code><\/pre>\n\n\n\n<p>\u6ce8\uff1a\u8bf7\u5c06 \u548c \u66ff\u6362\u4e3a\u60a8\u8bbe\u7f6e\u7684\u5b9e\u9645\u5b89\u5168\u5bc6\u7801\u3002<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Nginx \u670d\u52a1\u5668\u914d\u7f6e\u4e0e 502 \u89e3\u51b3<\/strong><\/li>\n<\/ol>\n\n\n\n<p>\u5173\u952e\u4fee\u590d\u70b9\uff1a \u786e\u4fdd Nginx Worker \u8fdb\u7a0b\u7528\u6237\u4e0e PHP-FPM Socket \u6743\u9650\u4e00\u81f4\u3002\u901a\u8fc7\u68c0\u67e5 \/etc\/nginx\/nginx.conf\uff0c\u6211\u4eec\u5c06 user \u6307\u4ee4\u4ece nginx; \u4fee\u6539\u4e3a user www-data;\uff0c\u5e76\u91cd\u542f\u670d\u52a1\uff0c\u4ece\u800c\u89e3\u51b3\u4e86 502 Bad Gateway (Permission denied) \u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u914d\u7f6e\u7684 Nginx \u7ad9\u70b9\u6587\u4ef6 \/etc\/nginx\/conf.d\/blog.conf \u786e\u4fdd\u4e86 HTTP \u5230 HTTPS \u7684\u91cd\u5b9a\u5411\uff0c\u5e76\u9884\u7559\u4e86 Certbot \u9a8c\u8bc1\u8def\u5f84\u3002<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u81ea\u52a8 SSL \u8bc1\u4e66\u96c6\u6210 (Let&#8217;s Encrypt)<\/strong><\/li>\n<\/ol>\n\n\n\n<p>\u4e3a\u5b9e\u73b0\u81ea\u52a8\u7eed\u671f\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 Nginx \u914d\u7f6e\u6765\u6307\u5411 Let&#8217;s Encrypt \u7684\u6807\u51c6\u8bc1\u4e66\u8def\u5f84\uff0c\u5e76\u4f9d\u8d56 Certbot \u81ea\u52a8\u5b8c\u6210\u90e8\u7f72\u548c\u5b9a\u65f6\u7eed\u671f\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u4e0b\u4e00\u6b65\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p>\u8fd0\u884c Certbot \u5ba2\u6237\u7aef\u5b8c\u6210\u9996\u6b21\u9a8c\u8bc1\u548c\u90e8\u7f72\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot --nginx -d blog.8912345.xyz<\/code><\/pre>\n\n\n\n<p>Certbot \u5c06\u81ea\u52a8\u5b8c\u6210\u8bc1\u4e66\u7684\u83b7\u53d6\u3001\u914d\u7f6e\u5199\u5165 blog.conf\uff0c\u5e76\u8bbe\u7f6e Cron \u4efb\u52a1\u8fdb\u884c\u540e\u7eed\u7eed\u671f\u3002<\/p>\n\n\n\n<p class=\"is-style-text-subtitle has-medium-font-size\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u672c\u6587\u6863\u8be6\u7ec6\u8bb0\u5f55\u4e86\u5728 Linux \u73af\u5883\u4e0b\uff0c\u901a\u8fc7 wp-cli \u5feb\u901f\u90e8\u7f72 WordPress \u5b9e\u4f8b\uff0c\u5e76\u7ed3\u5408 Nginx \u4f5c\u4e3a Web \u670d\u52a1\u5668\uff0c\u914d\u7f6e certbot \u5b9e\u73b0\u57df\u540d SSL \u8bc1\u4e66\u7684\u81ea\u52a8\u83b7\u53d6\u4e0e\u7eed\u671f\u8fc7\u7a0b\u3002 1. \u73af\u5883\u51c6\u5907\u4e0e\u6838\u5fc3\u6587\u4ef6\u90e8\u7f72 1.1 \u6570\u636e\u5e93\u51c6\u5907 \u5b8c\u6210\u6570\u636e\u5e93\u7684\u521b\u5efa\u3001\u7528\u6237\u6388\u6743\u548c\u6570\u636e\u5e93\u7684\u521b\u5efa\u3002 1.2 \u5b89\u88c5 WP-CLI \u901a\u8fc7 Phar \u5305\u5b89\u88c5 WP-CLI \u4ee5\u5b9e\u73b0\u65e0\u5934\u90e8\u7f72\uff1a 1.3 \u90e8\u7f72 WordPress \u6838\u5fc3 \u6211\u4eec\u5c06\u7f51\u7ad9\u6839\u76ee\u5f55\u5b9a\u5728 \/var\/www\/html\/blog\uff0c\u5e76\u786e\u4fdd\u6240\u6709\u6743\u5f52\u4e8e Web \u670d\u52a1\u5668\u7528\u6237 www-data\uff0c\u4ee5\u907f\u514d\u6743\u9650\u51b2\u7a81\uff1a \u6ce8\uff1a\u8bf7\u5c06 \u548c &hellip; <a href=\"https:\/\/blog.8912345.xyz\/?p=7\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/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":[],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7"}],"version-history":[{"count":3,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":11,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions\/11"}],"wp:attachment":[{"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.8912345.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}