为服务器部署SSL
证书是阿里云的免费单域名证书,采用文件验证方式,用DNS有点麻烦。
1.切换至Nginx
目录,打开nginx.conf
配置文件
cd /etc/nginx/sites-enabled/
nano default
(or vim default)
如果你改过,不一定是default
2.在http
里添加如下的配置
server {
server_name 你的域名;
listen 443;
ssl on;
ssl_certificate 证书目录;
ssl_certificate_key 私匙目录;
}
# Ctrl+O保存 Ctrl+X退出
3.重启,检查是否正常
root@debian:/etc/nginx# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@debian:/etc/nginx# /etc/init.d/nginx restart
[ ok ] Restarting nginx (via systemctl): nginx.service.