使用Apache或Nginx在Ubuntu上安装Let’s Encrypt SSL

介绍

Let’s Encrypt是一个自动化、开放的证书颁发机构,为公众提供免费的TLS/SSL证书。该服务由互联网安全研究小组(ISRG)提供。本教程展示了如何使用Certbot安装向导在带有Apache或Nginx的Ubuntu 20.04服务器上安装Let’s Encrypt SSL证书。完成本教程后,服务器将拥有有效的证书,并将所有HTTP请求重定向到HTTPS。

先决条件

本教程假设您已使用Apache或Nginx部署了Vultr Ubuntu服务器,有一个指向服务器IP地址的域名,并且您以root登录。

1.安装Certbot

Certbot的推荐安装方法是使用Snap

  1. 验证快照是否为最新版本。$ sudo snap install core; sudo snap refresh core
  2. 删除certbot-auto和任何Certbot OS软件包。$ sudo apt-get remove certbot
  3. 使用Snap安装Certbot。$ sudo snap install --classic certbot
  4. 将Certbot链接到/usr/bin$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

2.安装证书

Run certbot to install the certificate. Full examples are below, here are descriptions of the command line options:

  • –apache:使用Apache Web服务器
  • –nginx:使用nginx Web服务器
  • –redirect:将所有HTTP请求重定向到HTTPS。
  • -d example.com -d www.example.com:安装多域(SAN)证书。您可以使用多达100d的域条目。
  • -m admin@example.com:此证书的通知电子邮件地址。
  • –同意:同意服务条款。

使用certbot --help了解更多信息。有关SAN证书的更多信息,请参阅Certbot常见问题解答

示例:Apache

为Apache运行Certbot。

# certbot --apache --redirect -d example.com -d www.example.com -m admin@example.com --agree-tos

示例:Nginx

  1. 在运行Certbot之前,请确保正确设置了server_name。编辑您的Nginx配置:# nano /etc/nginx/conf.d/default.conf
  2. 更新server_name以包含您的域名。server { server_name example.com www.example.com;
  3. 保存并退出文件。
  4. 为Nginx运行Certbot。# certbot --nginx --redirect -d example.com -d www.example.com -m admin@example.com --agree-tos

3.验证自动续订

Let’s Encrypt证书的有效期为90天。Certbot向导更新系统计时器和crontab,以自动续订您的证书。

  1. 验证计时器是否处于活动状态。# systemctl list-timers | grep 'certbot\|ACTIVATES'
  2. 验证crontab条目是否存在。# ls -l /etc/cron.d/certbot
  3. 验证续订过程是否可进行模拟运行。# certbot renew --dry-run

摘要

使用Certbot安装免费的Let’s Encrypt证书很简单。有关更多信息,请参阅官方Certbot安装文档。

来源: https://www.vultr.com/docs/setup-letsencrypt-on-linux

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇