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

相關文章
相關標籤/搜索