sudo apt-get install software-properties-common sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install certbot python-certbot-nginx certbot certonly --webroot -w /xxx -d www.ivhong.com -d ivhong.com -w /xxxx -d www.ivhui.com -d ivhui.com --agree-tos --email xxxx@163.com --------------参数解释 : * certonly 只获取证书 * --webroot 以webroot插件去获得证书 * -w 需配合--webroot参数一起使用,用来指定网站根目录 * -d 指定域名 * --agree-tos 用意ACME用户协议(如果省略此项,则在命令执行过程中会询问是否同意) * --email 指定邮箱用来接收一些通知(如果省略此项,则在命令执行过程中会要求填写) * (如果有多个域名,则按照一个 -w /var/www/example 后接一个 -d example.com 的形式继续输入。)
nginx 配置:
listen 443 ssl;
listen 80;
server_name ivhui.com www.ivhui.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/ivhong/www/ivhui/web;
# ssl on;//这里如果是on的话,http访问网址将会出错
ssl_certificate /etc/letsencrypt/live/www.ivhong.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.ivhong.com/privkey.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
来源:https://blog.csdn.net/qq_35751770/article/details/78018613