ubuntu 生成https证书 for let's encrypt

一、安装certbot(用于自动续约证书)

1.1 添加安装源

sudo add-apt-repository ppa:certbot/certbotpython

1.2 更新apt安装源

sudo apt-get updatenginx

1.3 安装

sudo apt-get install python-certbot-apacheapache

二、安装letsencrypt并生成证书

安装 letsencrypt

sudo apt-get install letsencryptbash

生成证书

letsencrypt certonly --agree-tos --email youname@qq.com -d www.xxxxx.com服务器

三、检查/etc/letsencrypt/live/www.xxxxx.com

目录,已经生成证书文件session

  • cert.pem: 你不用关心 (这个其实是服务器证书文件)spa

  • chain.pem: 你不用关心 (这个其实是… 本身看文档吧, 我没读懂. 貌似是个递归查找用的链式证书)code

  • fullchain.pem: cert.pem + chain.pem 的合体. 须要配置到 nginx 配置文件中的 ssl_certificate .server

  • privkey.pem: 私钥. 须要配置到 nginx 配置文件中的 ssl_certificate_key .递归

server {
    listen 443 ssl http2;
    # listen [::]:443 ssl http2;
    server_name www.gabin.top;


    # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
    
    ssl_certificate /etc/letsencrypt/live/www.xxxxx.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.xxxxx.com/privkey.pem;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    }
复制代码

续期

sudo letsencrypt renew

相关文章
相关标签/搜索