{"id":735,"date":"2016-12-13T22:29:48","date_gmt":"2016-12-13T14:29:48","guid":{"rendered":"https:\/\/yangwang.hk\/?p=735"},"modified":"2017-02-27T21:28:04","modified_gmt":"2017-02-27T13:28:04","slug":"lets-encrypt-%e4%b8%80%e4%b8%aa%e5%85%8d%e8%b4%b9%e7%9a%84ssl%e8%af%81%e4%b9%a6","status":"publish","type":"post","link":"https:\/\/yangwang.hk\/?p=735","title":{"rendered":"Let&#8217;s Encrypt, \u4e00\u4e2a\u514d\u8d39\u7684SSL\u8bc1\u4e66"},"content":{"rendered":"<p>\u5f53\u524dhttps\u6b63\u662f\u4e00\u4e2a\u8d8b\u52bf\uff0c\u800c\u4e00\u822c\u6765\u8bf4\uff0cssl\u8bc1\u4e66\u90fd\u662f\u6bd4\u8f83\u6602\u8d35\u7684\u3002<\/p>\n<p>\u867d\u7136\u67d0\u4e9b\u5382\u5546\u4e3a\u6211\u4eec\u63d0\u4f9b\u514d\u8d39\u7684ssl\u8bc1\u4e66\uff0c\u4f8b\u5982\u56fd\u5185\u8457\u540d\u7684\u6c83\u901a\uff0c\u7136\u800c\u7531\u4e8e\u67d0\u4e9b\u4e8b\u4ef6\uff0c\u5b83\u7684\u540d\u58f0\u5e76\u4e0d\u597d\uff0c\u800c\u90e8\u5206\u6d4f\u89c8\u5668\u4e5f\u51b3\u5b9a\u4e0d\u518d\u4fe1\u4efb\u5b83\u4eec\u6240\u7b7e\u53d1\u7684\u514d\u8d39\u8bc1\u4e66\uff0c\u800c\u8fd9\u65e0\u7591\u662f\u5bf9\u90a3\u4e9b\u4f7f\u7528\u5b83\u4eec\u8bc1\u4e66\u7684\u4eba\u7684\u4e00\u4e2a\u91cd\u5927\u6253\u51fb\u3002<\/p>\n<p>\u8fd9\u65f6\u5019\uff0c\u5c31\u8be5\u6211\u4eec\u7684Lets&#8217; Encrypt\u9686\u91cd\u767b\u573a\u4e86\uff01<\/p>\n<p>\u8fd9\u4e2a\u540d\u5b57\u542c\u8d77\u6765\u5c31\u7ed9\u4eba\u4e00\u79cd\u4eb2\u8fd1\u7684\u611f\u89c9\uff0cLet&#8217;s Encrypt \u662f\u4e00\u9879\u7531\u4e92\u8054\u7f51\u5b89\u5168\u7814\u7a76\u5c0f\u7ec4\u63d0\u4f9b\u7684\u514d\u8d39\u670d\u52a1\u3002\u4e3b\u8981\u8d5e\u52a9\u5546\u5305\u62ec\u7535\u5b50\u524d\u54e8\u57fa\u91d1\u4f1a\uff0cMozilla\u57fa\u91d1\u4f1a\uff0cAkamai\u4ee5\u53ca\u601d\u79d1\u3002<\/p>\n<p>\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u6211\u4eec\u8fd9\u5c31\u6765\u770b\u4e00\u4e0b\u600e\u4e48\u5728\u4f60\u7684\u7f51\u7ad9\u4e0a\u4f7f\u7528let&#8217;s encrypt\u7b7e\u53d1ssl\u8bc1\u4e66\uff08\u4ee5Ubuntu\u73af\u5883\u4e3a\u4f8b\uff09\u3002<\/p>\n<p>\u548c\u666e\u901a\u7684\u8bc1\u4e66\u7b7e\u53d1\u4e0d\u540c\uff0c\u5b83\u4e0d\u9700\u8981\u4ec0\u4e48csr\uff0c\u4f60\u6240\u9700\u8981\u505a\u7684\u53ea\u662f\u8fd0\u884c\u4e00\u4e2a\u7a0b\u5e8f\u3002\u5b83\u5c31\u662fcertbot<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u5fc5\u987b\u8fd0\u884c\u5728\u6258\u7ba1\u7f51\u7ad9\u7684\u670d\u52a1\u5668\u4e0a\uff0c\u82f1\u6587\u5bf9\u65b9\u9700\u8981\u901a\u8fc7\u8bbf\u95ee\u60a8\u7684\u7f51\u7ad9\u6765\u9a8c\u8bc1\u4f60\u662f\u5426\u662f\u8be5\u7f51\u7ad9\u7684\u6240\u6709\u8005<\/p>\n<p>\u9996\u5148\u6211\u4eec\u6765\u5b89\u88c5\u5b83<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\nwget https:\/\/dl.eff.org\/certbot-auto\r\nchmod a+x certbot-auto\r\n.\/certbot-auto\r\n\r\n<\/pre>\n<p>\u524d\u9762\u4e24\u884c\u547d\u4ee4\u5206\u522b\u662f\u4e0b\u8f7d\u7a0b\u5e8f\uff0c\u8d4b\u4e88\u811a\u672c\u53ef\u6267\u884c\u6743\u9650\uff0c\u800c\u6700\u540e\u4e00\u6b65\u5219\u662f\u5b89\u88c5\u4f9d\u8d56\u3002\u8bf7\u6839\u636e\u63d0\u793a\u5b89\u88c5\u5b8c\u6bd5\u5373\u53ef<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u7b7e\u53d1\u4e86<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\ncertbot-auto certonly --email \u57df\u540d\u7ba1\u7406\u90ae\u7bb1 --agree-tos --webroot -w \u7f51\u7ad9\u6839\u76ee\u5f55 -d \u7f51\u7ad9\u57df\u540d1 -d \u7f51\u7ad9\u57df\u540d2\r\n\r\n<\/pre>\n<p>\u4f9d\u6b64\u7c7b\u63a8\uff0c\u5982\u679c\u4f60\u7684\u7f51\u7ad9\u5141\u8bb8\u591a\u4e2a\u57df\u540d\u8bbf\u95ee\uff0c\u53ea\u7528\u5c06\u4ed6\u4eec\u5168\u90e8\u4f9d\u7167-d \u57df\u540d\u7684\u683c\u5f0f\u6dfb\u52a0\u4e0a\u5373\u53ef\uff0c\u5982\u679c\u53ea\u5141\u8bb8\u4e00\u4e2a\u57df\u540d\u8bbf\u95ee\uff0c\u90a3\u4e48\u5199\u4e0a\u4e00\u4e2a\u5c31\u662f\u4e86\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u56e0\u4e3a\u9a8c\u8bc1\u4f1a\u5728\u7f51\u7ad9\u76ee\u5f55\u5199\u4e00\u4e2a\u7528\u4e8e\u9a8c\u8bc1\u7684\u4e34\u65f6\u6587\u4ef6\uff0c\u5982\u679c\u4f60\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c\u7684\u7528\u6237\u4e0d\u5177\u6709\u5199\u6743\u9650\u7684\u7684\u8bdd\uff0c\u5b83\u5c06\u4f1a\u7533\u8bf7root\u6743\u9650<\/p>\n<p>\u7a0d\u540e\uff0c\u5982\u679c\u6ca1\u6709\u95ee\u9898\u7684\u8bdd\uff0c\u5c31\u4f1a\u6210\u529f\u5566\uff1a<\/p>\n<div id=\"attachment_737\" style=\"width: 675px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-737\" class=\"wp-image-737 size-large\" src=\"https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689-1024x467.png\" alt=\"\" width=\"665\" height=\"303\" srcset=\"https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689-1024x467.png 1024w, https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689-300x137.png 300w, https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689-660x301.png 660w, https:\/\/yangwang.hk\/wp-content\/uploads\/2016\/12\/21-08-09-689.png 1126w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><p id=\"caption-attachment-737\" class=\"wp-caption-text\">\u7b7e\u540d\u6210\u529f<\/p><\/div>\n<p>\u4f60\u5c06\u5728\u201c\u795d\u8d3a\u201d\u4e2d\u770b\u5230\u751f\u6210\u7684\u8bc1\u4e66\u7684\u8def\u5f84\uff1a\/etc\/letsencrypt\/live\/\u7f51\u7ad9\u6839\u76ee\u5f55\u6587\u4ef6\u5939\u540d\/fullchain.pem<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u5c06\u5b83\u6dfb\u52a0\u5230\u670d\u52a1\u5668\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6765<\/p>\n<p>\u5bf9\u4e8eApache\uff0c\u5728\u4f60\u7684\u865a\u62df\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d&lt;\/VirtualHost&gt;\u540e\u9762\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\u5c31\u53ef\u4ee5\u4e86<\/p>\n<p>&lt;VirtualHost *:443&gt;<br \/>\nDocumentRoot\u00a0 <strong>\u7f51\u7ad9\u76ee\u5f55<\/strong>\u00a0 #\u7f51\u7ad9\u76ee\u5f55<br \/>\nServerName <strong>\u57df\u540d \u00a0<\/strong> #\u4f60\u7684\u57df\u540d<br \/>\nServerAdmin <strong>\u90ae\u7bb1\u00a0 \u00a0\u00a0<\/strong> #\u4f60\u7684\u90ae\u7bb1<br \/>\nErrorLog &#8220;\/home\/wwwlogs\/<strong>\u7f51\u7ad9\u57df\u540d<\/strong>-error_log&#8221; \u00a0 #\u9519\u8bef\u65e5\u5fd7<br \/>\nCustomLog &#8220;\/home\/wwwlogs\/<strong>\u7f51\u7ad9\u57df\u540d<\/strong>-access_log&#8221; common \u00a0 \u00a0#\u8bbf\u95ee\u65e5\u5fd7<br \/>\nSSLEngine on<br \/>\nSSLCertificateFile \/etc\/letsencrypt\/live\/<strong>\u7f51\u7ad9\u6839\u76ee\u5f55\u540d<\/strong>\/fullchain.pem \u00a0 #\u6539\u6210\u4e0a\u9762certbot\u6210\u529f\u540e\u63d0\u793a\u4e2d\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u540d<br \/>\nSSLCertificateKeyFile \/etc\/letsencrypt\/live\/<strong>\u7f51\u7ad9\u6839\u76ee\u5f55\u540d<\/strong>\/privkey.pem \u00a0 \u00a0#\u76ee\u5f55\u548c\u4e0a\u9762\u4e00\u6837\uff0c\u53ea\u662f\u6587\u4ef6\u540d\u4e0d\u540c<br \/>\n&lt;Directory &#8220;<strong>\u7f51\u7ad9\u76ee\u5f55<\/strong>&#8220;&gt; \u00a0 #\u7f51\u7ad9\u76ee\u5f55<br \/>\nSetOutputFilter DEFLATE<br \/>\nOptions FollowSymLinks<br \/>\nAllowOverride All<br \/>\nOrder allow,deny<br \/>\nAllow from all<br \/>\nDirectoryIndex index.html index.php<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;<\/p>\n<p>\u6dfb\u52a0\u8fd9\u4e24\u884c\uff0c\u91cd\u542f\u4e00\u4e0bapache\u5c31\u597d\u5566<\/p>\n<p>nginx\u7684\u914d\u7f6e\u7c7b\u4f3c\uff0c\u53ea\u9700\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u751f\u6210\u7684ssl\u8bc1\u4e66\u79c1\u94a5\uff0c\u7136\u540e\u91cd\u542f\u670d\u52a1\u5373\u53ef<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e2a\u8bc1\u4e66\u6709\u6548\u671f\u53ea\u670990\u5929\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u65e0\u9650\u7eed\u671f<\/p>\n<p>\u6211\u4eec\u5148\u8fd0\u884c\u4e0b\u5217\u7684\u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u7528\u4e8e\u6d4b\u8bd5\u8bc1\u4e66\u7eed\u671f<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\ncertbot-auto renew --dry-run\r\n\r\n<\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5e76\u4e0d\u4f1a\u7ed9\u4f60\u751f\u6210\u771f\u6b63\u7684\u65b0\u8bc1\u4e66\uff0c\u53ea\u662f\u505a\u4e86\u4e00\u4e2a\u7eed\u671f\u6d4b\u8bd5<br \/>\n\u5982\u679c\u4f60\u6ca1\u6709\u9047\u5230\u4efb\u4f55\u9519\u8bef\uff0c\u90a3\u4e48\u4f60\u5c31\u53ef\u4ee5\u653e\u5fc3\u5927\u80c6\u7684\u5c06\u4e0b\u5217\u547d\u4ee4\u52a0\u5165corn\u4e4b\u7c7b\u7684\u8ba1\u5212\u4efb\u52a1\u4e2d\u4e86<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n\/\u8def\u5f84\/certbot-auto renew --quiet --no-self-upgrade\r\n\r\n<\/pre>\n<p>\u5f53\u7136\u522b\u5fd8\u4e86\u5c06\u201c\u8def\u5f84\u201d\u4fee\u6539\u4e3a\u4f60certbot\u5de5\u5177\u7684\u8def\u5f84\u54e6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524dhttps\u6b63\u662f\u4e00\u4e2a\u8d8b\u52bf\uff0c\u800c\u4e00\u822c\u6765\u8bf4\uff0cssl\u8bc1\u4e66\u90fd\u662f\u6bd4\u8f83\u6602\u8d35\u7684\u3002 \u867d\u7136\u67d0\u4e9b\u5382\u5546\u4e3a\u6211\u4eec\u63d0\u4f9b\u514d\u8d39\u7684ssl\u8bc1\u4e66\uff0c\u4f8b\u2026 <span class=\"read-more\"><a href=\"https:\/\/yangwang.hk\/?p=735\">Read More: Let&#8217;\u2026 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-735","post","type-post","status-publish","format-standard","hentry","category-9"],"views":2203,"_links":{"self":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=735"}],"version-history":[{"count":4,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/735\/revisions"}],"predecessor-version":[{"id":741,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/735\/revisions\/741"}],"wp:attachment":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}