{"id":22242,"date":"2024-02-05T11:59:23","date_gmt":"2024-02-05T11:59:23","guid":{"rendered":"https:\/\/server.hk\/blog\/22242\/"},"modified":"2024-09-12T07:50:47","modified_gmt":"2024-09-12T07:50:47","slug":"managing-ssl-certificates-on-your-usa-vps-lets-encrypt-and-certbot","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/22242\/","title":{"rendered":"\u7ba1\u7406\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7684SSL\u8b49\u66f8\uff1aLet&#8217;s Encrypt\u8207Certbot"},"content":{"rendered":"<h1 id=\"managing-ssl-certificates-on-your-usa-vps-lets-encrypt-and-certbot-DbpumByyPS\">\u7ba1\u7406\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7684SSL\u8b49\u66f8\uff1aLet&#8217;s Encrypt\u8207Certbot<\/h1>\n<p>\u4f7f\u7528SSL\u8b49\u66f8\u4fdd\u8b77\u60a8\u7684\u7db2\u7ad9\u5c0d\u65bc\u7dad\u8b77\u7528\u6236\u6578\u64da\u7684\u96b1\u79c1\u548c\u5b89\u5168\u81f3\u95dc\u91cd\u8981\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u5982\u4f55\u5728\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7ba1\u7406SSL\u8b49\u66f8\uff0c\u4f7f\u7528Let&#8217;s Encrypt\u548cCertbot\u3002<\/p>\n<h2 id=\"what-are-ssl-certificates-DbpumByyPS\">\u4ec0\u9ebc\u662fSSL\u8b49\u66f8\uff1f<\/h2>\n<p>SSL\uff08Secure Sockets Layer\uff09\u8b49\u66f8\u662f\u6578\u5b57\u8b49\u66f8\uff0c\u7528\u65bc\u5efa\u7acb\u7db2\u9801\u4f3a\u670d\u5668\u8207\u700f\u89bd\u5668\u4e4b\u9593\u7684\u52a0\u5bc6\u9023\u63a5\u3002\u5b83\u5011\u78ba\u4fdd\u5169\u8005\u4e4b\u9593\u50b3\u8f38\u7684\u6578\u64da\u4fdd\u6301\u5b89\u5168\uff0c\u4e26\u9632\u6b62\u672a\u7d93\u6388\u6b0a\u7684\u8a2a\u554f\u3002<\/p>\n<p>SSL\u8b49\u66f8\u5c0d\u65bc\u8655\u7406\u654f\u611f\u4fe1\u606f\u7684\u7db2\u7ad9\u5c24\u5176\u91cd\u8981\uff0c\u5982\u767b\u9304\u6191\u8b49\u3001\u4fe1\u7528\u5361\u8a73\u60c5\u6216\u500b\u4eba\u6578\u64da\u3002\u5b83\u5011\u4e0d\u50c5\u4fdd\u8b77\u60a8\u7684\u7528\u6236\uff0c\u9084\u63d0\u5347\u4e86\u60a8\u7db2\u7ad9\u7684\u4fe1\u8b7d\u548c\u53ef\u4fe1\u5ea6\u3002<\/p>\n<h2 id=\"introducing-lets-encrypt-DbpumByyPS\">\u4ecb\u7d39Let&#8217;s Encrypt<\/h2>\n<p>Let&#8217;s Encrypt\u662f\u4e00\u5bb6\u514d\u8cbb\u4e14\u958b\u653e\u7684\u8b49\u66f8\u6388\u6b0a\u6a5f\u69cb\uff08CA\uff09\uff0c\u63d0\u4f9bSSL\u8b49\u66f8\u3002\u5b83\u65e8\u5728\u4f7f\u7372\u53d6\u548c\u66f4\u65b0SSL\u8b49\u66f8\u7684\u904e\u7a0b\u76e1\u53ef\u80fd\u7c21\u55ae\u548c\u81ea\u52d5\u5316\u3002<\/p>\n<p>Let&#8217;s Encrypt\u7684\u4e3b\u8981\u512a\u52e2\u4e4b\u4e00\u662f\u5b83\u63d0\u4f9b\u57df\u540d\u9a57\u8b49\u7684\u8b49\u66f8\uff0c\u9019\u4e9b\u8b49\u66f8\u53ef\u4ee5\u5feb\u901f\u4e14\u5bb9\u6613\u5730\u767c\u884c\u3002\u9019\u4e9b\u8b49\u66f8\u53d7\u5230\u6240\u6709\u4e3b\u8981\u700f\u89bd\u5668\u548c\u64cd\u4f5c\u7cfb\u7d71\u7684\u4fe1\u4efb\uff0c\u4f7f\u5b83\u5011\u6210\u70ba\u5927\u591a\u6578\u7db2\u7ad9\u7684\u7d55\u4f73\u9078\u64c7\u3002<\/p>\n<h2 id=\"using-certbot-for-ssl-certificate-management-DbpumByyPS\">\u4f7f\u7528Certbot\u9032\u884cSSL\u8b49\u66f8\u7ba1\u7406<\/h2>\n<p>Certbot\u662f\u4e00\u500b\u6d41\u884c\u4e14\u5ee3\u6cdb\u4f7f\u7528\u7684\u7ba1\u7406SSL\u8b49\u66f8\u7684\u5de5\u5177\u3002\u5b83\u662f\u4e00\u500b\u958b\u6e90\u5ba2\u6236\u7aef\uff0c\u81ea\u52d5\u5316\u7372\u53d6\u3001\u66f4\u65b0\u548c\u5b89\u88ddLet&#8217;s Encrypt\u8b49\u66f8\u7684\u904e\u7a0b\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5728\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7ba1\u7406SSL\u8b49\u66f8\u4f7f\u7528Certbot\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"step-1-installing-certbot-DbpumByyPS\">\u6b65\u9a5f1\uff1a\u5b89\u88ddCertbot<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u60a8\u7684VPS\u4e0a\u5b89\u88ddCertbot\u3002Certbot\u5728\u5176\u7db2\u7ad9\u4e0a\u70ba\u5404\u7a2e\u64cd\u4f5c\u7cfb\u7d71\u63d0\u4f9b\u8a73\u7d30\u7684\u5b89\u88dd\u6307\u5357\u3002\u8acb\u78ba\u4fdd\u6309\u7167\u60a8VPS\u64cd\u4f5c\u7cfb\u7d71\u7684\u5177\u9ad4\u6307\u5357\u9032\u884c\u64cd\u4f5c\u3002<\/p>\n<h3 id=\"step-2-obtaining-ssl-certificates-DbpumByyPS\">\u6b65\u9a5f2\uff1a\u7372\u53d6SSL\u8b49\u66f8<\/h3>\n<p>\u5b89\u88ddCertbot\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u70ba\u60a8\u7684\u57df\u540d\u7372\u53d6SSL\u8b49\u66f8\u3002\u7372\u53d6\u8b49\u66f8\u7684\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>sudo certbot certonly --webroot -w \/path\/to\/your\/website -d yourdomain.com -d www.yourdomain.com<\/code><\/pre>\n<p>\u5c07\u300c\/path\/to\/your\/website\u300d\u66ff\u63db\u70ba\u60a8\u7db2\u7ad9\u6839\u76ee\u9304\u7684\u5be6\u969b\u8def\u5f91\uff0c\u4e26\u5c07\u300cyourdomain.com\u300d\u66ff\u63db\u70ba\u60a8\u7684\u57df\u540d\u3002\u6b64\u547d\u4ee4\u5c07\u70ba\u60a8\u7684\u57df\u540d\u751f\u6210SSL\u8b49\u66f8\u4e26\u5b58\u5132\u5728\u60a8\u7684VPS\u4e0a\u3002<\/p>\n<h3 id=\"step-3-configuring-your-web-server-DbpumByyPS\">\u6b65\u9a5f3\uff1a\u914d\u7f6e\u60a8\u7684\u7db2\u9801\u4f3a\u670d\u5668<\/h3>\n<p>\u7372\u5f97SSL\u8b49\u66f8\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e\u60a8\u7684\u7db2\u9801\u4f3a\u670d\u5668\u4ee5\u4f7f\u7528\u5b83\u5011\u3002\u914d\u7f6e\u904e\u7a0b\u53d6\u6c7a\u65bc\u60a8\u4f7f\u7528\u7684\u7db2\u9801\u4f3a\u670d\u5668\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fApache\uff0c\u60a8\u53ef\u4ee5\u7de8\u8f2f\u865b\u64ec\u4e3b\u6a5f\u914d\u7f6e\u6587\u4ef6\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:443&gt;\r\n    ServerName yourdomain.com\r\n    DocumentRoot \/path\/to\/your\/website\r\n    SSLEngine on\r\n    SSLCertificateFile \/etc\/letsencrypt\/live\/yourdomain.com\/fullchain.pem\r\n    SSLCertificateKeyFile \/etc\/letsencrypt\/live\/yourdomain.com\/privkey.pem\r\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p>\u8acb\u5c07\u300cyourdomain.com\u300d\u66ff\u63db\u70ba\u60a8\u7684\u5be6\u969b\u57df\u540d\uff0c\u5c07\u300c\/path\/to\/your\/website\u300d\u66ff\u63db\u70ba\u60a8\u7db2\u7ad9\u7684\u6839\u76ee\u9304\u8def\u5f91\u3002<\/p>\n<h3 id=\"step-4-renewing-ssl-certificates-DbpumByyPS\">\u6b65\u9a5f4\uff1a\u66f4\u65b0SSL\u8b49\u66f8<\/h3>\n<p>Let&#8217;s Encrypt\u8b49\u66f8\u7684\u6709\u6548\u671f\u70ba90\u5929\u3002\u70ba\u4e86\u78ba\u4fddSSL\u4fdd\u8b77\u4e0d\u9593\u65b7\uff0c\u60a8\u9700\u8981\u5728\u5b83\u5011\u904e\u671f\u4e4b\u524d\u66f4\u65b0\u8b49\u66f8\u3002\u5e78\u904b\u7684\u662f\uff0cCertbot\u53ef\u4ee5\u70ba\u60a8\u81ea\u52d5\u8655\u7406\u9019\u4e00\u904e\u7a0b\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u8a2d\u7f6e\u4e00\u500bcron\u4f5c\u696d\u5b9a\u671f\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo certbot renew<\/code><\/pre>\n<p>\u6b64\u547d\u4ee4\u5c07\u81ea\u52d5\u66f4\u65b0\u4efb\u4f55\u5373\u5c07\u5230\u671f\u7684\u8b49\u66f8\u3002<\/p>\n<h2 id=\"summary-DbpumByyPS\">\u6458\u8981<\/h2>\n<p>\u7ba1\u7406\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7684SSL\u8b49\u66f8\u5c0d\u65bc\u4fdd\u8b77\u60a8\u7684\u7db2\u7ad9\u548c\u4fdd\u969c\u7528\u6236\u6578\u64da\u7684\u5b89\u5168\u81f3\u95dc\u91cd\u8981\u3002Let&#8217;s Encrypt\u548cCertbot\u70ba\u7372\u53d6\u3001\u66f4\u65b0\u548c\u5b89\u88ddSSL\u8b49\u66f8\u63d0\u4f9b\u4e86\u65b9\u4fbf\u548c\u81ea\u52d5\u5316\u7684\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<p>\u6309\u7167\u672c\u6587\u4e2d\u6982\u8ff0\u7684\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u5728\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7ba1\u7406SSL\u8b49\u66f8\u3002\u66f4\u591a\u95dc\u65bc\u9999\u6e2fVPS\u6258\u7ba1\u7684\u4fe1\u606f\u53ca\u5176\u5c0d\u60a8\u7db2\u7ad9\u7684\u597d\u8655\uff0c\u8acb\u8a2a\u554f<a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ba1\u7406\u60a8\u7684\u9999\u6e2fVPS\u4e0a\u7684SSL\u8b49\u66f8&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4927],"tags":[],"class_list":["post-22242","post","type-post","status-publish","format-standard","hentry","category-4927"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/22242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=22242"}],"version-history":[{"count":2,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/22242\/revisions"}],"predecessor-version":[{"id":23122,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/22242\/revisions\/23122"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=22242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=22242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=22242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}