使用 Certbot 并设置自动续期 SSL 证书

使用 Certbot 并设置自动续期 SSL 证书

步骤:

  1. 安装 Certbot:使用命令安装 Certbot:

    sudo yum install certbot
    
  2. 获取 SSL 证书:运行 Certbot 命令来获取并安装 SSL 证书。
    示例命令,替换其中的域名和路径信息:

    sudo certbot certonly --webroot -w /path/to/your/website -d your-domain.com -d www.your-domain.com
    

    这将使用 Certbot 的 webroot 插件来进行验证,并为你的域名生成 SSL 证书。确保将 /path/to/your/website 替换为你网站的根目录路径,your-domain.com 替换为你的实际域名。

  3. 设置自动续期:Certbot 支持设置自动续期任务,以确保你的 SSL 证书在到期前得到更新。你可以使用系统的计划任务工具(如 cron)来定期运行 Certbot 命令。
    示例:
    cron 任务配置,每天凌晨 2 点自动运行 Certbot:

    0 2 * * * certbot renew --quiet
    

    请使用合适的编辑器打开计划任务配置文件(通常是 /etc/crontab),将上述命令添加到文件末尾,并保存文件。Certbot 每天凌晨 2 点自动检查证书是否需要续期,并在需要时更新证书。

你可能感兴趣的:(linux,ssl,网络,服务器)