当前位置: 首页 > news >正文

在宝塔面板中,为自己的云服务器安装SSL证书,为所搭建的网站启用https(主要部分攻略)

前提条件

My HTTP website is running Nginx on Debian 10(或者11)

时间:2024-3-28 16:25:52

你的网站部署在Debain 10(或者11)的 Nginx上

安装单域名证书(默认)(非泛域名)

1 进入自己的云服务器的宝塔面板(即云服务器控制台的外网连接)

2 进入终端标签页

安装snap

进入这个网址

https://snapcraft.io/docs/installing-snapd

选择自己的服务器环境

以 Debian 为例

在终端运行这些指令

snap can be installed directly from the command line:

sudo apt update
sudo apt install snapd

Either log out and back in again, or restart your system, to ensure snap’s paths are updated correctly.

After this, install the core snap in order to get the latest snapd.

sudo snap install core

To test your system, install the hello-world snap and make sure it runs correctly:

sudo snap install hello-world
hello-world

如果曾经安装过Certbot packages

则需要先卸载移除这些内容

例如

sudo apt-get remove certbot
sudo dnf remove certbot
sudo yum remove certbot

Install Certbot

sudo snap install --classic certbot

Prepare the Certbot command

Execute the following instruction on the command line on the machine to ensure that the certbot command can be run.

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Run this command to get a certificate and have Certbot edit your nginx configuration automatically to serve it, turning on HTTPS access in a single step.(小白推荐)

sudo certbot --nginx

注意,如果你的nginx不在默认目录/etc/nginx/nginx.conf

则需要修改这个命令,修改后如下

以/www/server/nginx/conf/nginx.conf为例

sudo certbot --nginx-server-root /www/server/nginx/conf

启用自动续订SSL证书

Test automatic renewal

The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

The command to renew certbot is installed in one of the following locations:

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers

3 Confirm that Certbot worked,重新进入自己的网站,看看是否变成了https协议

        To confirm that your site is set up properly, visit https://yourwebsite.com/ in your browser and look for the lock icon in the URL bar.

        完成

4 去宝塔网站标签页(从这里开始建议不必理会,可以先去看看其他大神)

5 选择自己的网站项目

这里以go项目为例

6 粘贴自己的证书内容(内容哪里找?看第7步)

7 去宝塔文件系统的这个目录/etc/letsencrypt/live/www.xxxxx.com

分别对应privkey.pem 和 fullchain.pem

附录

指定nginx目录,且指定域名,示例

sudo certbot --nginx --nginx-server-root /www/server/nginx/conf -d www.xxxxx.com

http://www.lryc.cn/news/327590.html

相关文章:

  • 学习JavaEE的日子 Day32 线程池
  • @Transactional 注解使用的注意事项
  • 电商系列之库存
  • Apache HBase(二)
  • 【设计模式】原型模式详解
  • 企微侧边栏开发(内部应用内嵌H5)
  • 如何确定最优的石油管道位置
  • FPGA 图像边缘检测(Canny算子)
  • 2024.3.28学习笔记
  • 33.HarmonyOS App(JAVA)鸿蒙系统app数据库增删改查
  • 寄主机显示器被快递搞坏了怎么办?怎么破?
  • python爬虫-bs4
  • SpringBoot学习之ElasticSearch下载安装和启动(Mac版)(三十一)
  • OC对象 - Block解决循环引用
  • Java设计模式之装饰器模式
  • Java基础知识总结(25)
  • Vue3 实现基于token 用户登录
  • 在word中显示Euclid Math One公式的问题及解决(latex公式,无需插件)
  • 江协科技STM32:按键控制LED光敏传感器控制蜂鸣器
  • 最佳矢量绘图设计软件Sketch for Mac v99.5 最新中文激活版
  • 【IntelliJ IDEA】运行测试报错解决方案(附图)
  • 【Kotlin】List、Set、Map简介
  • OpenCV 形态学处理函数
  • 互联网摸鱼日报(2024-03-27)
  • 2014年认证杯SPSSPRO杯数学建模B题(第二阶段)位图的处理算法全过程文档及程序
  • C++基本语法
  • Node Sass does not yet support your current environment
  • 长陆工业自动控制系统邀您到场参观2024第13届生物发酵产品与技术装备展
  • 数据仓库——维度表更新
  • Web3创作整理 - 2024-02-23 ~ 2024-03-25