1、先建立 一个ssl目录、这个【ssl】只是个目录名字只要能记住你写什么都行

# cd /
# cd etc/nginx
# mkdir ssl

2、将申请的证书文件 【.cer】【.csr】【.key】 代表你的证书文件名 比如:xxx.xxx.key,xxx.xxx.csr,xxx.xxx.cer
将这三个文件上传到 ssl目录下 代用!
3、设置nginx.conf配置文件
在里面找到有关443端口的代码

# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }

把前面的# 全部打开
将修改下面的ssl证书路径

先cd到etc/nginx目录下
# vim nginx.conf
默认路径:
ssl_certificate "/etc/pki/nginx/server.crt";
ssl_certificate_key "/etc/pki/nginx/private/server.key";
修改为:刚开始创建的ssl目录现在派上用场,但要根据你的实际情况填写
ssl_certificate "/etc/nginx/ssl/xxx.xxx.cer";
ssl_certificate_key "/etc/nginx/ssl/xxx.xxx.key";
路径与xxx.xxx请自行替换
按esc,shift+z+z保存退出
# service nginx restart #重启nginx服务