nginx_SSL证书安装配置指南

打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件找到

# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

去掉注释

# HTTPS server
server {
    listen       443 ssl;
    server_name  localhost;#您的域名

    ssl_certificate      cert.pem; #证书文件
    ssl_certificate_key  cert.key; #私钥文件

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location / {
        root   html;
        index  index.html index.htm;
    }
}

保存配置文件,重启nginx

centos5/6

service nginx start #启动
service nginx restart #重新启动
service nginx stop #停止服务

centos7

systemctl start nginx #启动
systemctl restart nginx #重新启动
systemctl stop nginx #停止服务

ubuntu

sudo /etc/init.d/nginx start #启动服务
sudo /etc/init.d/nginx restart #重启服务
sudo /etc/init.d/nginx stop #停止服务