1、命令配置
1 2 3 4
| curl https://get.acme.sh | sh
alias acme.sh=~/.acme.sh/acme.sh
|
2、申请证书
1 2 3 4
| acme.sh --issue --server letsencrypt --dns dns_dp -d xichangyou.com -d www.xichangyou.com --webroot /home/leellun/webroot
acme.sh --issue --server letsencrypt -d xichangyou.com -d www.xichangyou.com --webroot /home/leellun/webroot
|
3、安装证书
1
| acme.sh --install-cert -d xichangyou.com -d www.xichangyou.com --key-file /usr/local/nginx/certs/xichangyou.com.key --fullchain-file /usr/local/nginx/certs/xichangyou.com.pem
|
4、配置nginx
在/usr/local/nginx/conf.d目录下 ,创建xichangyou.com.conf配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| server { listen 443 ssl; server_name localhost;
ssl_certificate /usr/local/nginx/certs/xichangyou.com.pem; ssl_certificate_key /usr/local/nginx/certs/xichangyou.com.key;
ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /usr/local/nginx/www/html; }
location / { root /usr/local/nginx/html; index index.html index.htm; } }
|
在nginx配置文件目录conf中引入
nginx.conf内容:
1 2 3 4
| http{ .... include /usr/local/nginx/conf.d
|
5 设置自动更新
1
| acme.sh --upgrade --auto-upgrade
|