获取脚本

source ~/.bashrc
curl https://get.acme.sh |sh

浏览器打开找到自己的域名服务商(建议用谷歌浏览器翻译中文找)

https://github.com/acmesh-official/acme.sh/wiki/dnsapi

我的域名服务商是namesilo以下是namesilo操作步骤

获取apikey https://www.namesilo.com/account/api-manager

复制key

export Namesilo_Key="xxxxxxxxxxxxx"   #xxxxxx改成key
acme.sh --issue --dns dns_namesilo --dnssleep 900 -d baidu.com -d www.baidu.com    #baidu.com和www.baidu.com改成自己的域名

等待15分钟生成

证书文件 fullchain.cer
秘钥文件 域名.key

宝塔添加秘钥

没有面板的手动修改nginx配置文件

server {
    listen 80;
    listen 443 ssl;
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    ssl_certificate 证书.crt;
    ssl_certificate_key 密钥.key;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;
  #ssl配置结束
    server_name  www.dhhblog.com dhhblog.com;
    root   站点目录;
    index  index.php index.html index.htm;
    location ~ .*\.(php|php5)?$ {
        root 站点目录;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}

 

重启nginx即可