编辑/usr/local/nginx/conf/vhost/ 目录下,站点对应的conf文件,将其中的

    ssl_certificate /root/ssl/pan.pem;
    ssl_certificate_key /root/ssl/pan.key;

替换为自己的证书和key文件,重启lnmp即可,使用lnmp ssl add 不仅麻烦,而且因为原来的信息还在,并不会生效。

    server
    {
        listen 80;
        #listen [::]:80;
        server_name www.yoursite.com ;
        return 301 https://www.yoursite.com$request_uri;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.yoursite.com;

        include rewrite/other.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php-pathinfo.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/www.yoursite.com.log;
    }

server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name www.yoursite.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.yoursite.com/;
        ssl on;
        ssl_certificate /root/ssl/pan.pem;
        ssl_certificate_key /root/ssl/pan.key;
        ssl_session_timeout 500m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "XXXXX";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

        include rewrite/other.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php-pathinfo.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/www.yoursite.com.log;
    }