linux下使用Letsencrypt為Nginx服務器的網站添加SSL証書

安裝letsencrypt

git clone https://github.com/letsencrypt/letsencrypt /home/username/letsencrypt

生成証書

cd letsencrypt/

./letsencrypt-auto certonly --webroot-path /var/www/xxx.com/ --agree-tos --email [email protected] -d xxx.com -d www.xxx.com -d subdomain1.xxx.com -d subdomain2.xxx.com -d subdomain3.xxx.com

#key會存在/etc/letsencrypt/live/domain_name

Nginx setting

編輯nginx的site配置文件

添加以下的並保存

ssl on;
ssl_certificate /etc/letsencrypt/live/xxx.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxx.com/privkey.pem;

重啟Ngnix

service ngnix restart