{"id":421,"date":"2021-05-09T10:28:26","date_gmt":"2021-05-09T02:28:26","guid":{"rendered":"https:\/\/heoffice.com\/?p=421"},"modified":"2022-01-15T10:17:27","modified_gmt":"2022-01-15T02:17:27","slug":"%e9%98%bf%e9%87%8c%e4%ba%91%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%9d%e5%a1%94linuxcertbot%e5%ae%9e%e7%8e%b0%e7%bd%91%e7%ab%99%e7%9a%84ssl-https%e8%ae%bf%e9%97%ae","status":"publish","type":"post","link":"https:\/\/heoffice.com\/?p=421","title":{"rendered":"\u963f\u91cc\u4e91\u670d\u52a1\u5668+\u5b9d\u5854Linux+Certbot\u5b9e\u73b0\u7f51\u7ad9\u7684SSL, HTTPS\u8bbf\u95ee"},"content":{"rendered":"\n<p>\u9700\u8981: \u5df2\u5b89\u88c5\u4e86\u5b9d\u5854Linux\u9762\u677f\u7684\u963f\u91cc\u4e91\u670d\u52a1\u5668\uff08Centos7\uff09\uff0ccertbot.eff.org<\/p>\n\n\n\n<p>1.  \b\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5snap<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install epel-release\nsudo yum install snapd\nsudo systemctl enable --now snapd.socket\nsudo systemctl start snapd\nsudo ln -s \/var\/lib\/snapd\/snap \/snap\nsudo snap install core; sudo snap refresh core<\/code><\/pre>\n\n\n\n<p>\u53c2\u89c1\uff1a<a href=\"https:\/\/snapcraft.io\/docs\/installing-snap-on-centos\">https:\/\/snapcraft.io\/docs\/installing-snap-on-centos<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>2. \u901a\u8fc7Snap\u5b89\u88c5Certbot<\/p>\n\n\n\n<p>\u79fb\u9664\u4e4b\u524d\u7684\u8bc1\u4e66\u8f6f\u4ef6\uff0c\u4f7f\u7528snap\u5b89\u88c5Certbot\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum remove certbot\nsudo snap install --classic certbot\nsudo ln -s \/snap\/bin\/certbot \/usr\/bin\/certbot<\/code><\/pre>\n\n\n\n<p>3. \u624b\u52a8\u4f7f\u7528Certbot \u83b7\u53d6\u8bc1\u4e66<\/p>\n\n\n\n<p>\u5b9d\u5854\u7cfb\u7edf\u7684Nginx\u914d\u7f6e\u6587\u4ef6\u5b58\u653e\u5728\/www\/server\/nginx\/conf\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0bCertbot\u7684Nginx\u63d2\u4ef6\u65e0\u6cd5\u627e\u5230nginx.conf\u914d\u7f6e\u6587\u4ef6\uff0c\u505a\u4e2a\u8f6f\u8fde\u63a5\u8ba9Certbot\u80fd\u627e\u5230nginx.conf\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ln -s \/www\/server\/nginx\/conf \/etc\/nginx<\/code><\/pre>\n\n\n\n<p>\u624b\u52a8\u8fd0\u884c\u83b7\u53d6\u8bc1\u4e66\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>certbot run -a manual -i nginx -d example.com<\/code><\/pre>\n\n\n\n<p>\u628a\u5176\u4e2d\u7684example.com\u6362\u6210\u81ea\u5df1\u7684\u57df\u540d\uff0cCertbot\u4f1a\u4e3a\u60a8\u751f\u4e00\u4e2a\u5bc6\u94a5\uff0c\u5e76\u63d0\u793a\u628a\u8be5\u5bc6\u94a5\u653e\u5230\u7f51\u7ad9\u7684\/www\/wwwroot\/example.com\/.well-known\/acme-challenge\u76ee\u5f55\u4e0b\uff0c\u786e\u4fddhttp:\/\/example.com\/.well-known\/acme-challenge\/McVrtxbb6vdx6tSCnULPgNxAhcyKjDpld-a2j_abcd\u80fd\u8bbf\u95ee\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u8ba9Certbot\u5b8c\u6210\u8bc1\u4e66\u6ce8\u518c\u4e0e\u914d\u7f6e\uff0c\u5b8c\u6210\u540e\u4f1a\u6709\u63d0\u793a\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><\/pre>\n\n\n\n<p>4. \u67e5\u770b\u7ed3\u679c<\/p>\n\n\n\n<p>\u8fdb\u5165\u5b9d\u5854\u7cfb\u7edf\uff0c\u6253\u5f00\u7f51\u7ad9\u7684\u914d\u7f6e\u7a97\u53e3\uff0cSSL\u9009\u9879\u5361\uff0c\u5c31\u80fd\u770b\u5230\u5df2\u4e3a\u60a8\u81ea\u52a8\u751f\u6210Let&#8217;s Encrypt\u514d\u8d39\u8bc1\u4e66<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"930\" src=\"https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl-1024x930.png\" alt=\"\" class=\"wp-image-428\" srcset=\"https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl-1024x930.png 1024w, https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl-300x272.png 300w, https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl-768x697.png 768w, https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl-425x386.png 425w, https:\/\/heoffice.com\/wp-content\/uploads\/2021\/05\/ssl.png 1282w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\u628a\u914d\u7f6e\u6587\u4ef6\/etc\/letsencrypt\/renewal\/xxx.conf \u4e2d\u7684authenticator\u6539\u4e3anginx\nauthenticator = nginx<\/code><\/pre>\n\n\n\n<p>\u542f\u7528crontab <\/p>\n\n\n\n<p>30 2 * * * \/usr\/local\/bin\/certbot-auto renew &gt;&gt; \/www\/server\/panel\/logs\/certbot.log<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u8981: \u5df2\u5b89\u88c5\u4e86\u5b9d\u5854Linux\u9762\u677f\u7684\u963f\u91cc\u4e91\u670d\u52a1\u5668\uff08Centos7\uff09\uff0ccertbot.eff.org 1. \b\u5728&#8230;<\/p>\n","protected":false},"author":1,"featured_media":424,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web"],"acf":[],"_links":{"self":[{"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/posts\/421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heoffice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=421"}],"version-history":[{"count":5,"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/posts\/421\/revisions"}],"predecessor-version":[{"id":449,"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/posts\/421\/revisions\/449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/heoffice.com\/index.php?rest_route=\/wp\/v2\/media\/424"}],"wp:attachment":[{"href":"https:\/\/heoffice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heoffice.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heoffice.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}