{"id":584,"date":"2016-05-26T15:46:26","date_gmt":"2016-05-26T07:46:26","guid":{"rendered":"http:\/\/blog.nami.idv.tw\/?p=584"},"modified":"2019-04-22T12:50:48","modified_gmt":"2019-04-22T04:50:48","slug":"%e5%9c%a8-lamp-%e5%b0%8e%e5%85%a5-lets-encrypt-for-apache","status":"publish","type":"post","link":"https:\/\/blog.nami.idv.tw\/?p=584","title":{"rendered":"\u5728 Linux (Ubuntu) \u5c0e\u5165 Let\u2019s Encrypt (for Apache)"},"content":{"rendered":"<p><em>\u6587\u7ae0\u66f4\u65b0\u6642\u9593\uff1a2019-03-13<\/em><\/p>\n<h2>\u74b0\u5883\uff1a<\/h2>\n<p>OS: Ubuntu 18.04 LTS<br \/>\nWeb server: Apache: 2.4<\/p>\n<h2>\u521d\u59cb\u5316\uff1a<\/h2>\n<ol>\n<li>\u5982\u679c\u9084\u6c92\u88dd git \u7684\u8a71:<br \/>\nsudo apt-get install git<\/li>\n<li>cd \/opt<\/li>\n<li>sudo git clone https:\/\/github.com\/certbot\/certbot<\/li>\n<li>cd certbot<\/li>\n<li>\u81ea\u52d5\u5316\u5b89\u88dd\u4f9d\u5b58\u5957\u4ef6\u4ee5\u5efa\u7acb\u8d77\u57f7\u884c\u74b0\u5883:<br \/>\n.\/certbot-auto<\/li>\n<\/ol>\n<h2>\u55ae\u4e00\u4e3b\u6a5f\u540d\u7a31 (Single host) \u6b65\u9a5f\uff1a<\/h2>\n<ol>\n<li>\u958b\u59cb\u81ea\u52d5\u5316\u8a2d\u5b9a (for apache)<br \/>\n.\/certbot-auto --apache<\/li>\n<li>\u9078\u64c7\u8981\u7c3d\u767c\u6191\u8b49\u7684\u4e3b\u6a5f\u540d\u7a31<\/li>\n<li>\u9078\u64c7\u672a\u4f86\u7684\u9023\u7dda\u65b9\u5f0f\n<ol>\n<li>HTTP, HTTPS \u4e26\u5b58<\/li>\n<li>\u5168\u90e8\u5c0e\u5411 HTTPS (\u6703\u81ea\u52d5\u5728\u8a72\u4e3b\u6a5f\u8a2d\u5b9a\u6a94\u52a0\u4e0a rewrite rule)<\/li>\n<\/ol>\n<\/li>\n<li>\u6e2c\u8a66\u662f\u5426\u6b63\u5e38\u7c3d\u767c<br \/>\nhttps:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=[\u4e3b\u6a5f\u540d\u7a31]<\/li>\n<\/ol>\n<h2>Wildcard Certificate \u6b65\u9a5f\uff1a<\/h2>\n<ol>\n<li>\u63a1\u7528\u624b\u52d5\u8a2d\u5b9a\uff0c\u6311\u6230\u6a21\u5f0f\u63a1\u7528 DNS TXT \u7d00\u9304:<br \/>\n.\/certbot-auto certonly --manual --preferred-challenges dns-01 --server https:\/\/acme-v02.api.letsencrypt.org\/directory --agree-tos --email yourname@example.com -d \"*.yourdomain.com,yourdomain.com\"<\/li>\n<li>\u63a5\u4e0b\u4f86\u6703\u51fa\u73fe\u8981\u52a0\u5165 DNS TXT \u7684\u5167\u5bb9:<br \/>\n<a href=\"https:\/\/blog.nami.idv.tw\/wp-content\/uploads\/2016\/05\/Screenshot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-677 size-full\" src=\"https:\/\/blog.nami.idv.tw\/wp-content\/uploads\/2016\/05\/Screenshot.png\" alt=\"\" width=\"648\" height=\"409\" srcset=\"https:\/\/blog.nami.idv.tw\/wp-content\/uploads\/2016\/05\/Screenshot.png 648w, https:\/\/blog.nami.idv.tw\/wp-content\/uploads\/2016\/05\/Screenshot-300x189.png 300w\" sizes=\"auto, (max-width: 648px) 100vw, 648px\" \/><\/a><\/li>\n<li>\u52a0\u5165\u5f8c\u7528\u4ee5\u4e0b\u6307\u4ee4\u78ba\u8a8d\u662f\u5426\u5df2\u7d93\u751f\u6548:<br \/>\n[Linux] dig _acme-challenge.yourdomain.com txt<br \/>\n[Windows] nslookup -q=txt _acme-challenge.yourdomain.com<\/li>\n<li>\u751f\u6548\u5f8c\u6309\u4e0b Enter<\/li>\n<li>\u7531\u65bc\u672c\u7bc4\u4f8b\u767b\u9304\u4e86 *.yourdomain.com \u53ca yourdomain.com \u5169\u500b\u57df\u540d\uff0c\u6240\u4ee5 2~3 \u6b65\u9a5f\u6703\u8dd1\u5169\u6b21\uff08\u8acb\u6ce8\u610f\u90a3\u500b\u6311\u6230\u7528\u7684\u503c xxxxxxxx \u6bcf\u6b21\u90fd\u4e0d\u540c\uff0c\u6b64\u5916\uff0c\u4e0d\u8981\u522a\u9664\u524d\u4e00\u500b TXT Record \u800c\u662f\u5efa\u7acb\u540c\u540d\u7684\u7b2c\u4e8c\u500b TXT Record\uff09<\/li>\n<li>\u7b49\u7b2c\u4e8c\u500b\u751f\u6548\u7b49\u4e86\u4e00\u6bb5\u6642\u9593\uff0c\u56e0\u70ba\u8981\u770b\u4e3b\u6a5f\u7684 TTL<\/li>\n<li>\u4ee5\u5f8c\u9084\u662f\u5f97\u4f7f\u7528\u4ee5\u4e0a\u76f8\u540c\u6d41\u7a0b\u4f86\u66f4\u65b0\u6191\u8b49<\/li>\n<li>\u7531\u65bc\u6b64\u65b9\u5f0f<strong>\u50c5\u7533\u8acb\u6191\u8b49<\/strong>\u4f46\u6c92\u6709\u81ea\u52d5\u8a2d\u5b9a\u5230 Web Server\uff0c\u6240\u4ee5\u5f8c\u7e8c\u8981\u81ea\u5df1\u624b\u52d5\u8a2d\u5b9a<\/li>\n<\/ol>\n<h2>\u7dad\u8b77\uff1a<\/h2>\n<ul>\n<li>\u5217\u51fa\u6240\u6709\u6191\u8b49:<br \/>\n.\/certbot-auto certificates<\/li>\n<li>\u66f4\u65b0\u6240\u6709\u6191\u8b49:<br \/>\n.\/certbot-auto renew<\/li>\n<li>\u66f4\u65b0\u55ae\u4e00\u6191\u8b49:<br \/>\n.\/certbot-auto renew --cert-name [\u6191\u8b49\u540d\u7a31]<\/li>\n<li>\u522a\u9664\u6191\u8b49:<br \/>\n.\/certbot-auto delete --cert-name [\u6191\u8b49\u540d\u7a31]<\/li>\n<\/ul>\n<h2>Reference:<\/h2>\n<ul>\n<li><a href=\"https:\/\/letsencrypt.org\/getting-started\/\">https:\/\/letsencrypt.org\/getting-started\/<\/a><\/li>\n<li><a href=\"https:\/\/certbot.eff.org\/docs\/\">https:\/\/certbot.eff.org\/docs\/<\/a><\/li>\n<\/ul>\n<h2>Issues:<\/h2>\n<ul>\n<li>\u5982\u679c\u767c\u751f <strong>couldn't get currently installed version<\/strong> \u932f\u8aa4\u7684\u8a71\uff0c\u89e3\u6c7a\u8fa6\u6cd5 <a href=\"https:\/\/github.com\/certbot\/certbot\/issues\/4776\">https:\/\/github.com\/certbot\/certbot\/issues\/4776<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u66f4\u65b0\u6642\u9593\uff1a2019-03-13 \u74b0\u5883\uff1a OS: Ubuntu 18.04 L &hellip; <a href=\"https:\/\/blog.nami.idv.tw\/?p=584\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-584","post","type-post","status-publish","format-standard","hentry","category-web-technology"],"_links":{"self":[{"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":14,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":686,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/686"}],"wp:attachment":[{"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nami.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}