阅读量:2
在Ubuntu上安装Nginx的SSL证书,通常使用Let’s Encrypt免费证书,步骤如下:
- 安装Nginx和Certbot:执行
sudo apt update,然后sudo apt install nginx certbot python3-certbot-nginx。 - 获取SSL证书:用
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com命令获取证书,Certbot会自动配置Nginx。 - 手动配置(可选):若需手动配置,编辑
/etc/nginx/sites-available/yourdomain.com,添加如下内容:
server {
listen 443 ssl;
server_name yourdomain.com www.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /var/www/html;
index index.html index.htm;
}
}
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
return 301 https://$host$request_uri;
}
- 测试与重载:运行
sudo nginx -t测试配置,无误后用sudo systemctl reload nginx重载Nginx。 - 自动续订:Certbot会自动设置定时任务续订证书,可用
sudo certbot renew --dry-run测试。
以上就是关于“ubuntu nginx ssl证书怎么安装”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm