{"id":502,"date":"2020-03-28T23:36:45","date_gmt":"2020-03-28T23:36:45","guid":{"rendered":"http:\/\/142f65cdc30644fc819293a1d0c9ebc8"},"modified":"2020-04-29T16:51:34","modified_gmt":"2020-04-29T08:51:34","slug":"142f65cdc30644fc819293a1d0c9ebc8","status":"publish","type":"post","link":"https:\/\/www.netnewpower.net\/?p=502","title":{"rendered":"\u5982\u4f55\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Let&#8217;s Encrypt SSL\u8bc1\u4e66"},"content":{"rendered":"<p>Apache\u662fApache\u57fa\u91d1\u4f1a\u57281995\u5e74\u5f00\u53d1\u7684web\u670d\u52a1\u5668\uff0c<strong>Apache<\/strong>\u662f\u5e94\u7528\u6700\u5e7f\u6cdb\u3001\u6700\u7a33\u5b9a\u53ef\u9760\u7684web\u670d\u52a1\u5668\u4e4b\u4e00\u3002Apache web\u670d\u52a1\u5668\u9700\u8981\u6709\u6548\u7684SSL\u8bc1\u4e66\uff0c\u4ee5\u4fbf\u901a\u8fc7\u52a0\u5bc6\u901a\u4fe1\u6765\u542f\u7528\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4e4b\u95f4\u7684web\u5b89\u5168\u6027\u3002<\/p>\n<p><strong>Let&#8217;s Encrypt<\/strong>\u662f\u4e00\u4e2a\u63d0\u4f9b\u514d\u8d39<strong>SSL<\/strong>\u8bc1\u4e66\u7684\u8bc1\u4e66\u9881\u53d1\u673a\u6784\uff0c\u5b83\u5728\u6240\u6709\u4e3b\u8981web\u6d4f\u89c8\u5668\u4e2d\u90fd\u662f\u73b0\u6210\u7684\u3002<strong>Certbot<\/strong>\u662f\u7531Electronic Frontier Foundation\uff08EFF\uff09\u5f00\u53d1\u7684\u52a0\u5bc6\u5ba2\u6237\u7aef\u3002\u8ba9\u6211\u4eec\u52a0\u5bc6SSL\u8bc1\u4e66\u5c06\u4e3aApache\u63d0\u4f9b\u66f4\u597d\u7684\u5b89\u5168\u6027\uff0c\u5e76\u4e14\u4f7f\u7528Certbot\u5de5\u5177\u5f88\u5bb9\u6613\u96c6\u6210\u3002<\/p>\n<p>\u672c\u7bc7\u4e3b\u8981\u8bb2\u8ff0\u5982\u4f55\u5728Ubuntu\u670d\u52a1\u5668\u4e0a\u90e8\u7f72Let\u2019s Encrypt SSL\u8bc1\u4e66\uff08\u672c\u4f8b\u73af\u5883Ubuntu 18.04\uff09\uff0c\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6559\u7a0b\uff1a<\/p>\n<p><strong>\u4e00\u3001\u5b89\u88c5\u6240\u9700\u7684\u8f6f\u4ef6\u5305<\/strong><\/p>\n<p>Apache Web\u670d\u52a1\u5668\u548cCertbot\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\u3002\u9ed8\u8ba4\u7684Ubuntu\u5b58\u50a8\u5e93\u5305\u542bApache\u548cCertbot\u7684\u6240\u6709\u5305\u3002\u9ad8\u7ea7\u6253\u5305\u5de5\u5177\uff08APT\uff09\u662fUbuntu\u7684\u9ed8\u8ba4\u5305\u7ba1\u7406\u5668\uff0c\u5b83\u53ef\u4ee5\u975e\u5e38\u6709\u6548\u5730\u5b89\u88c5\u8fd9\u4e9b\u5305\u3002<\/p>\n<p>1\u3001\u9996\u5148\u5220\u9664\u5e76\u5237\u65b0\u65e7\u7684apt\u5b58\u50a8\u5e93\u7f13\u5b58\u3002<\/p>\n<p>sudo apt clean all<\/p>\n<p>2\u3001\u7136\u540e\u66f4\u65b0\u5b58\u50a8\u5e93\u4ee5\u52a0\u8f7d\u6700\u65b0\u7684\u5305\u4fe1\u606f\u3002<\/p>\n<p>sudo apt update<\/p>\n<p>3\u3001\u60a8\u9700\u8981\u6267\u884c\u5230\u7684\u5b8c\u5168\u5347\u7ea7\u4ee5\u66f4\u65b0\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n<p>sudo apt dist-upgrade<br \/>\n4\u3001\u4e00\u65e6\u5b9e\u73b0\u4e86\u66f4\u65b0\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u9ed8\u8ba4\u7684apt\u5305\u5b89\u88c5\u7a0b\u5e8f\u4e3aApache\u5b89\u88c5Apache web\u670d\u52a1\u5668\u548cCertbot\uff08\u8ba9\u6211\u4eec\u52a0\u5bc6\u5ba2\u6237\u7aef\uff09\u3002<\/p>\n<p>sudo apt install apache2 python-certbot-apache<\/p>\n<p>\u6210\u529f\u5b89\u88c5\u6240\u9700\u8f6f\u4ef6\u5305\u540e\u3002\u8ba9\u6211\u4eec\u914d\u7f6e\u4e0b\u4e00\u6b65\u4e2d\u4ecb\u7ecd\u7684\u9632\u706b\u5899\u3002<\/p>\n<p><strong>\u4e8c\u3001\u914d\u7f6eUFW\u9632\u706b\u5899<\/strong><\/p>\n<p>UFW\uff08\u7edf\u4e00\u9632\u706b\u5899\uff09\u662fUbuntu\u4f7f\u7528\u7684\u9ed8\u8ba4\u9632\u706b\u5899\u3002\u5b83\u662f\u4e00\u4e2a\u57fa\u4e8e\u7aef\u53e3\u7684\u9632\u706b\u5899\uff0c\u6613\u4e8e\u914d\u7f6e\u548c\u7ba1\u7406\u3002Apache web\u670d\u52a1\u5668\u9700\u8981HTTP\u548cHTTPS\u670d\u52a1\u6765\u5141\u8bb8\u5e38\u89c4\u548c\u52a0\u5bc6\u7684\u901a\u4fe1\u3002<\/p>\n<p>1\u3001\u4e3a\u4e86\u5141\u8bb8\u8fd9\u4e9b\u670d\u52a1\uff0c\u60a8\u9700\u8981\u6253\u5f00HTTP\uff0880\uff09\u548cHTTPS\uff08443\uff09\u7aef\u53e3\uff0c\u8fd9\u662fApache web\u670d\u52a1\u5668\u6240\u5fc5\u9700\u7684\u3002\u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u9632\u706b\u5899\u4e2d\u5b9e\u73b0\u57fa\u4e8e\u7aef\u53e3\u7684\u89c4\u5219\u6765\u5141\u8bb8\u8fd9\u4e9b\u7aef\u53e3\u3002<\/p>\n<p>sudo ufw allow http<br \/>\nsudo ufw allow https<\/p>\n<p>2\u3001SSH\uff0822\uff09\u7aef\u53e3\u662f\u767b\u5f55\u5230\u670d\u52a1\u5668\u7684\u4e00\u4e2a\u91cd\u8981\u7aef\u53e3\uff0c\u4f46\u4ece\u5b89\u5168\u6027\u65b9\u9762\u6765\u8bf4\uff0c\u6700\u597d\u5728\u6709\u9650\u7684\u6743\u9650\u4e0b\u4fdd\u7559\u8be5\u7aef\u53e3\u3002\u8fd9\u5c06\u4f7f\u57fa\u4e8e\u7aef\u53e3\u7684\u5b89\u5168\u6027\u80fd\u591f\u4fdd\u62a4\u6b64\u7aef\u53e3\u514d\u53d7\u66b4\u529b\u653b\u51fb\u3002<\/p>\n<p>sudo ufw limit ssh<\/p>\n<p>3\u3001\u5c06\u6240\u6709\u89c4\u5219\u6dfb\u52a0\u5230\u9632\u706b\u5899\u540e\uff0c\u60a8\u9700\u8981\u542f\u52a8\u9632\u706b\u5899\u5e76\u5728\u542f\u52a8\u65f6\u542f\u7528\u5b83\uff0c\u4ee5\u4fbf\u5728\u542f\u52a8\u671f\u95f4\u4fdd\u7559\u9632\u706b\u5899\u670d\u52a1\u3002<\/p>\n<p>sudo ufw enable<\/p>\n<p>4\u3001\u6240\u6709\u64cd\u4f5c\u5b8c\u6210\u540e\uff0c\u5c31\u8981\u68c0\u67e5\u662f\u5426\u6dfb\u52a0\u4e86\u7aef\u53e3\u3002<\/p>\n<p>sudo ufw status<\/p>\n<p>5\u3001\u5982\u679c\u6240\u6709\u914d\u7f6e\u90fd\u5f88\u5b8c\u7f8e\uff0c\u90a3\u4e48\u5b83\u770b\u8d77\u6765\u5c31\u50cf\u7ed9\u5b9a\u7684\u793a\u4f8b\u8f93\u51fa\u3002<\/p>\n<p>Status: active<\/p>\n<p>To Action From<br \/>\n&#8212; &#8212;&#8212; &#8212;-<br \/>\n80\/tcp ALLOW Anywhere<br \/>\n443\/tcp ALLOW Anywhere<br \/>\n22\/tcp LIMIT Anywhere<br \/>\n80\/tcp (v6) ALLOW Anywhere (v6)<br \/>\n443\/tcp (v6) ALLOW Anywhere (v6)<br \/>\n22\/tcp (v6) LIMIT Anywhere (v6)<\/p>\n<p>\u5b8c\u6210\u8fd9\u4e00\u6b65\u540e\uff0c\u73b0\u5728\u8ba9\u6211\u4eec\u8fdb\u5165\u4e0b\u4e00\u6b65\u3002<\/p>\n<p><strong>\u4e09\u3001\u914d\u7f6eApache VirtualHost<\/strong><\/p>\n<p>Apache VirtualHost\u5141\u8bb8\u591a\u4e2a\u57df\u540d\u5728\u5355\u4e2aApache web\u670d\u52a1\u5668\u4e0a\u63d0\u4f9b\u5185\u5bb9\u3002\u5b83\u5141\u8bb8\u5b89\u5168\u673a\u5236\u4e3a\u591a\u4e2a\u57df\u540d\u4fdd\u7559\u4e0d\u540c\u7684\u76ee\u5f55\u3002\u8fd9\u662f\u4e00\u79cd\u6210\u672c\u6548\u76ca\u9ad8\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u5728\u4f4e\u6d41\u91cf\u4e0b\u5f00\u7bb1\u5373\u7528\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c06\u628a\u591a\u4e2a\u7f51\u7ad9\u50cf\u5171\u4eab\u73af\u5883\u4e00\u6837\u4fdd\u5b58\u5728\u4e00\u53f0\u673a\u5668\u4e0a\u3002<\/p>\n<p>1\u3001\u9996\u5148\u8981\u6dfb\u52a0\u57df\u540d\u7684\u865a\u62df\u4e3b\u673a\u3002\u7ed9\u5b9a\u7684\u793a\u4f8bApache VirtualHost\u914d\u7f6e\u6587\u4ef6\u5c06\u5e2e\u52a9\u60a8\u514d\u8d39\u83b7\u53d6\u52a0\u5bc6SSL\u8bc1\u4e66\u3002\u5728Ubuntu\u4e2d\uff0cApache VirtualHost\u4f4d\u4e8eApache\u914d\u7f6e\u76ee\u5f55\u4e2d\u7684sites available\u548csites enabled\u76ee\u5f55\u4e0b\u3002<\/p>\n<p>sudo nano \/etc\/apache2\/sites-available\/example.com.conf<\/p>\n<p>2\u3001\u5c06\u7ed9\u5b9a\u7684\u884c\u6dfb\u52a0\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5e76\u786e\u4fdd\u60a8\u7684\u57df\u540d\u5fc5\u987b\u6dfb\u52a0\u5230\u670d\u52a1\u5668\u540d\u548c\u670d\u52a1\u5668\u522b\u540d\u4e2d\uff0c\u4ee5\u4fbf\u83b7\u53d6\u52a0\u5bc6SSL\u8bc1\u4e66\u3002<\/p>\n<p>&lt;VirtualHost *:80&gt;<br \/>\nServerName example.com<br \/>\nServerAlias www.<span style=\"color: #000000;\">example<\/span>.com<br \/>\nServerAdmin admin@<span style=\"color: #000000;\">example<\/span>.com<br \/>\nDocumentRoot \/var\/www\/html\/<br \/>\n&lt;\/VirtualHost&gt;<\/p>\n<p>&lt;Directory \/var\/www\/html&gt;<br \/>\nRequire all granted<br \/>\nAllowOverride None<br \/>\n&lt;\/Directory&gt;<\/p>\n<p>\u5b8c\u6210\u540e\uff0c\u6309Ctrl+O\u4fdd\u5b58\uff0c\u6309Ctrl+X\u9000\u51fanano\u7f16\u8f91\u5668\u3002<\/p>\n<p>3\u3001\u5728\u6dfb\u52a0Apache VirtualHost\u914d\u7f6e\u6587\u4ef6\u4e4b\u540e\uff0c\u60a8\u5fc5\u987b\u5728\u53ef\u7528\u7ad9\u70b9\u548c\u542f\u7528\u7ad9\u70b9\u7684\u76ee\u5f55\u4e4b\u95f4\u521b\u5efa\u7b26\u53f7\u94fe\u63a5\u3002\u8fd9\u5141\u8bb8\u60a8\u5728\u4efb\u4f55\u65f6\u5019\u66f4\u6539\u7ad9\u70b9\u53ef\u7528\u76ee\u5f55\u4e2d\u7684VirtualHost\u914d\u7f6e\u6587\u4ef6\uff0c\u5b83\u5c06\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u8f6f\u94fe\u63a5\u81ea\u52a8\u590d\u5236\u5230\u7ad9\u70b9\u542f\u7528\u76ee\u5f55\u3002<\/p>\n<p>sudo ln -s \/etc\/apache2\/sites-available\/example.com.conf \/etc\/apache2\/sites-enabled\/example.com.conf<\/p>\n<p>4\u3001\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u6b63\u786e\uff0c\u6b64\u547d\u4ee4\u8fd8\u5c06\u68c0\u67e5Apache\u914d\u7f6e\u6587\u4ef6\u7684\u8bed\u6cd5\u3002<\/p>\n<p>sudo apachectl -t<\/p>\n<p>5\u3001\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u90a3\u4e48\u5b83\u5c06\u8bed\u6cd5OK\u663e\u793a\u4e3a\u8f93\u51fa\u3002\u5982\u679c\u51fa\u73b0\u4efb\u4f55\u95ee\u9898\uff0c\u8bf7\u91cd\u65b0\u9a8c\u8bc1Apache VirtualHost\u6587\u4ef6\u3002\u5168\u90e8\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u542f\u52a8\u670d\u52a1\u4ee5\u66f4\u6539\u6548\u679c\u3002<\/p>\n<p>sudo systemctl restart apache2<\/p>\n<p>\u5728\u6dfb\u52a0Apache VirtualHost\u6587\u4ef6\u4e4b\u540e\uff0c\u662f\u65f6\u5019\u901a\u8fc7\u751f\u6210\u514d\u8d39\u7684Let&#8217;s Encrypt\u52a0\u5bc6\u8bc1\u4e66SSL\u6765\u4fdd\u62a4Apache web\u670d\u52a1\u5668\u4e86\u3002<\/p>\n<p>\u56db\u3001\u751f\u6210Let&#8217;s Encrypt SSL\u8bc1\u4e66<\/p>\n<p>1\u3001Certbot\u662fLet&#8217;s Encrypt\u5ba2\u6237\u7aef\uff0c\u7528\u4e8e\u81ea\u52a8\u751f\u6210Let&#8217;s Encrypt SSL\u5e76\u4e0eApache web\u670d\u52a1\u5668\u96c6\u6210\u3002\u8fd9\u4e00\u6b65\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u4f7f\u7528Certbot\uff0c\u4f7f\u7528\u5b50\u6807\u5fd7apache\u5b9e\u73b0\u4e0eapache\u7684\u81ea\u52a8SSL\u96c6\u6210\uff0c\u5e76\u4e3a\u6240\u6709\u9700\u8981SSL\u8bc1\u4e66\u7684\u57df\u540d\u4f7f\u7528flag-d\u3002<\/p>\n<p>sudo certbot &#8211;apache -d example.com -d www.example.com<\/p>\n<p>2\u3001\u5728\u4ea4\u4e92\u5f0f\u8bbe\u7f6eLet&#8217;s Encrypt\u811a\u672c\u671f\u95f4\uff0c\u9700\u8981\u63d0\u4f9b\u4e00\u4e9b\u4fe1\u606f\u3002\u60a8\u5c06\u63d0\u4f9b\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u4ee5\u83b7\u53d6\u7535\u5b50\u90ae\u4ef6\u901a\u77e5\uff0c\u5176\u4e2d\u5305\u542b\u4e0eLet&#8217;s Encrypt SSL\u8bc1\u4e66\u76f8\u5173\u7684\u5404\u79cd\u4fe1\u606f\u3002<\/p>\n<p>Saving debug log to \/var\/log\/letsencrypt\/letsencrypt.log<br \/>\nPlugins selected: Authenticator apache, Installer apache<br \/>\nEnter email address (used for urgent renewal and security notices) (Enter &#8216;c&#8217; to<br \/>\ncancel): admin@example.com<\/p>\n<p>3\u3001\u63a5\u53d7\u670d\u52a1\u6761\u6b3e\u5e76\u9009\u62e9\u60a8\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u662f\u5426\u4e0eElectronic Frontier Foundation\u5171\u4eab\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nPlease read the Terms of Service at<br \/>\nhttps:\/\/letsencrypt.org\/documents\/LE-SA-v1.2-November-15-2017.pdf. You must<br \/>\nagree in order to register with the ACME server at<br \/>\nhttps:\/\/acme-v01.api.letsencrypt.org\/directory<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n(A)gree\/(C)ancel: A<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nWould you be willing to share your email address with the Electronic Frontier<br \/>\nFoundation, a founding partner of the Let&#8217;s Encrypt project and the non-profit<br \/>\norganization that develops Certbot? We&#8217;d like to send you email about EFF and<br \/>\nour work to encrypt the web, protect its users and defend digital rights.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n(Y)es\/(N)o: N<\/p>\n<p>4\u3001\u5168\u90e8\u5b8c\u6210\u540e\uff0cLet&#8217;s Encrypt\u5c06\u6267\u884c\u4e24\u9879\u514d\u8d39\u83b7\u53d6\u7684\u5c1d\u8bd5\uff1aLet&#8217;s Encrypt SSL\u8bc1\u4e66\u3002\u5982\u679c\u6240\u6709\u914d\u7f6e\u90fd\u6b63\u786e\uff0c\u90a3\u4e48\u5728\u5b8c\u6210\u6240\u6709\u6b65\u9aa4\u540e\uff0c\u60a8\u5c06\u83b7\u5f97Let&#8217;s Encrypt SSL\u8bc1\u4e66\u3002<\/p>\n<p>Obtaining a new certificate<br \/>\nPerforming the following challenges:<br \/>\nhttp-01 challenge for example.com<br \/>\nhttp-01 challenge for www.example.com<br \/>\nEnabled Apache rewrite module<br \/>\nWaiting for verification&#8230;<br \/>\nCleaning up challenges<br \/>\nCreated an SSL vhost at \/etc\/apache2\/sites-available\/000-default-le-ssl.conf<br \/>\nEnabled Apache socache_shmcb module<br \/>\nEnabled Apache ssl module<br \/>\nDeploying Certificate to VirtualHost \/etc\/apache2\/sites-available\/000-default-le-ssl.conf<br \/>\nEnabling available site: \/etc\/apache2\/sites-available\/000-default-le-ssl.conf<\/p>\n<p>5\u3001\u5982\u679cCertbot\u627e\u4e0d\u5230\u60a8\u7684\u670d\u52a1\u5668virtualhost\uff0c\u5b83\u5c06\u8be2\u95ee\u60a8\u8981\u6dfb\u52a0\u54ea\u4e2a\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>We were unable to find a vhost with a ServerName or Address of www.example.com.<br \/>\nWhich virtual host would you like to choose?<br \/>\n(note: conf files with multiple vhosts are not yet supported)<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n1: 000-default.conf | | | Enabled<br \/>\n2: 000-default-le-ssl.conf | example.com | HTTPS | Enabled<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nSelect the appropriate number [1-2] then [enter] (press &#8216;c&#8217; to cancel): 2<br \/>\nDeploying Certificate to VirtualHost \/etc\/apache2\/sites-available\/000-default-le-ssl.conf<\/p>\n<p>6\u3001\u6b64\u6b65\u9aa4\u9002\u7528\u4e8e\u4ece\u4e0d\u5b89\u5168\u7684HTTP\u6d41\u91cf\u91cd\u5b9a\u5411\u5230\u5b89\u5168\u7684HTTPS\u6d41\u91cf\u3002<\/p>\n<p>Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n1: No redirect &#8211; Make no further changes to the webserver configuration.<br \/>\n2: Redirect &#8211; Make all requests redirect to secure HTTPS access. Choose this for<br \/>\nnew sites, or if you&#8217;re confident your site works on HTTPS. You can undo this<br \/>\nchange by editing your web server&#8217;s configuration.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nSelect the appropriate number [1-2] then [enter] (press &#8216;c&#8217; to cancel): 2<br \/>\nEnabled Apache rewrite module<br \/>\nRedirecting vhost in \/etc\/apache2\/sites-enabled\/000-default.conf to ssl vhost in \/etc\/apache2\/sites-available\/000-de<\/p>\n<p>7\u3001\u5f53\u6240\u6709\u6b65\u9aa4\u90fd\u6210\u529f\u5b9e\u73b0\u5e76\u6700\u7ec8\u751f\u6210\u52a0\u5bc6SSL\u8bc1\u4e66\u65f6\uff0c\u5b83\u5c06\u663e\u793a\u7ed9\u5b9a\u7684\u4fe1\u606f\u3002<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nCongratulations! You have successfully enabled https:\/\/example.com and<br \/>\nhttps:\/\/www.example.com<\/p>\n<p>You should test your configuration at:<br \/>\nhttps:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=example.com<br \/>\nhttps:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=www.example.com<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>IMPORTANT NOTES:<br \/>\n&#8211; Congratulations! Your certificate and chain have been saved at:<br \/>\n\/etc\/letsencrypt\/live\/example.com\/fullchain.pem<br \/>\nYour key file has been saved at:<br \/>\n\/etc\/letsencrypt\/live\/example.com\/privkey.pem<br \/>\nYour cert will expire on 2019-08-02. To obtain a new or tweaked<br \/>\nversion of this certificate in the future, simply run certbot again<br \/>\nwith the &#8220;certonly&#8221; option. To non-interactively renew *all* of<br \/>\nyour certificates, run &#8220;certbot renew&#8221;<br \/>\n&#8211; Your account credentials have been saved in your Certbot<br \/>\nconfiguration directory at \/etc\/letsencrypt. You should make a<br \/>\nsecure backup of this folder now. This configuration directory will<br \/>\nalso contain certificates and private keys obtained by Certbot so<br \/>\nmaking regular backups of this folder is ideal.<br \/>\n&#8211; If you like Certbot, please consider supporting our work by:<\/p>\n<p>Donating to ISRG \/ Let&#8217;s Encrypt: https:\/\/letsencrypt.org\/donate<br \/>\nDonating to EFF: https:\/\/eff.org\/donate-le<\/p>\n<p>8\u3001\u6210\u529f\u751f\u6210Let&#8217;s Encrypt\u8bc1\u4e66\u540e\uff0c\u4f1a\u81ea\u52a8\u6dfb\u52a0\u8be5\u8bc1\u4e66\u4ee5\u4fdd\u62a4Apache\u3002\u5728\u4e0b\u4e00\u6b65\u4e2d\uff0c\u60a8\u5c06\u8bbe\u7f6ecrontab\u4ee5\u81ea\u52a8\u66f4\u65b0Let&#8217;s Encrypt SSL\u8bc1\u4e66\u3002<\/p>\n<p><strong>\u4e94\u3001\u81ea\u52a8\u66f4\u65b0Let&#8217;s Encrypt\u8bc1\u4e66<\/strong><\/p>\n<p>Let&#8217;s Encrypt SSL\u8bc1\u4e66\u7684\u6709\u6548\u671f\u4e3a\u81ea\u9881\u53d1\u4e4b\u65e5\u8d7790\u5929\u3002\u56e0\u6b64\uff0c\u5728\u8bc1\u4e66\u5230\u671f\u524d\u66f4\u65b0\u8bc1\u4e66\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002crontab\u5141\u8bb8\u5728\u8ba1\u5212\u65f6\u95f4\u81ea\u52a8\u8ba1\u5212\u7eed\u8ba2\u4efb\u52a1\u3002<br \/>\n\u8981\u5c06\u6761\u76ee\u6dfb\u52a0\u5230crontab\uff0c\u60a8\u9700\u8981\u8ba1\u5212\u65f6\u95f4\uff0c\u5e76\u4e14certbot\u7eed\u8ba2\u5c06\u5728\u914d\u7f6e\u7684\u8ba1\u5212\u65f6\u95f4\u5185\u5b9a\u671f\u8fd0\u884c\u3002<\/p>\n<p>sudo crontab -e<\/p>\n<p>\u5728\u7b2c\u4e00\u6b21\u8fd0\u884c\u671f\u95f4\uff0c\u5b83\u4f1a\u8be2\u95ee\u9ed8\u8ba4\u7f16\u8f91\u5668\u60a8\u5fc5\u987b\u9009\u62e9nano\u4f5c\u4e3a\u6587\u672c\u7f16\u8f91\u5668\u3002<\/p>\n<p>Select an editor. To change later, run &#8216;select-editor&#8217;.<br \/>\n1. \/bin\/nano &lt;&#8212;- easiest<br \/>\n2. \/usr\/bin\/vim.basic<br \/>\n3. \/usr\/bin\/vim.tiny<br \/>\n4. \/bin\/ed<\/p>\n<p>Choose 1-4 [1]: 1<\/p>\n<p>\u5c06\u7ed9\u5b9a\u7684\u884c\u6dfb\u52a0\u5230crontab\u4e2d\uff0c\u4ee5\u4fbf\u572805:00 AM\u542f\u7528\u81ea\u52a8Let&#8217;s Encrypt \u7eed\u8ba2\u3002\u8fd9\u5c06\u5728\u5230\u671f\u65e5\u524d\u81ea\u52a8\u7eed\u8ba2SSL\u8bc1\u4e66\u3002<\/p>\n<p>0 5 * * * \/usr\/bin\/certbot renew &#8211;post-hook &#8220;systemctl restart apache2&#8221;<\/p>\n<p>\u5b8c\u6210\u540e\uff0c\u6309Ctrl+O\u4fdd\u5b58\uff0c\u6309Ctrl+X\u9000\u51fanano\u7f16\u8f91\u5668\u3002<br \/>\n\u68c0\u67e5\u8fd9\u4e9b\u6761\u76ee\u662f\u5426\u6dfb\u52a0\u5230crontab\u3002<\/p>\n<p>sudo crontab -l<\/p>\n<p>\u6b64\u547d\u4ee4\u663e\u793a\u6dfb\u52a0\u7684cronjobs\u7684\u8f93\u51fa\u3002\u8fd9\u610f\u5473\u7740\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u6dfb\u52a0\u4e86crontab\u6761\u76ee\uff0c\u7528\u4e8e\u81ea\u52a8\u7eed\u8ba2Let&#8217;s Encrypt SSL\u8bc1\u4e66\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u4f7f\u7528Let&#8217;s Encrypt SSL\u8bc1\u4e66\u6765\u4fdd\u62a4Apache\u3002\u5b83\u8fd8\u5c06\u542f\u7528\u4f7f\u7528crontab\u81ea\u52a8\u66f4\u65b0Let&#8217;s Encrypt SSL\u8bc1\u4e66\u3002\u8fd9\u5c06\u901a\u8fc7\u5b9e\u73b0Let&#8217;s Encrypt SSL\u8bc1\u4e66\u6765\u4fdd\u62a4\u60a8\u7684web\u5c5e\u6027\u3002\u6b64\u65f6\uff0c\u60a8\u53ef\u4ee5\u4e3a\u60a8\u7684\u7f51\u7ad9\u4f7f\u7528\u5b89\u5168\u534f\u8baeHTTPS\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache\u662fApache\u57fa\u91d1\u4f1a\u57281995\u5e74\u5f00\u53d1\u7684web\u670d\u52a1\u5668\uff0cApache\u662f\u5e94\u7528\u6700\u5e7f\u6cdb\u3001\u6700\u7a33\u5b9a\u53ef\u9760<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[44,45,32,46,43],"class_list":["post-502","post","type-post","status-publish","format-standard","hentry","category-25","tag-Apache","tag-Certbot","tag-https","tag-SSL","tag-Ubuntu"],"_links":{"self":[{"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/posts\/502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=502"}],"version-history":[{"count":1,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions"}],"predecessor-version":[{"id":538,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions\/538"}],"wp:attachment":[{"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netnewpower.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}