Skip to content
Menu
HE'S BLOG
  • Home
  • One Page
  • Home page
  • Links
  • Mac
  • Windows
  • Program
  • AI
HE'S BLOG
2021年5月9日2022年1月15日

阿里云服务器+宝塔Linux+Certbot实现网站的SSL, HTTPS访问

需要: 已安装了宝塔Linux面板的阿里云服务器(Centos7),certbot.eff.org

1. 在服务器上安装snap

sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo systemctl start snapd
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install core; sudo snap refresh core

参见:https://snapcraft.io/docs/installing-snap-on-centos

2. 通过Snap安装Certbot

移除之前的证书软件,使用snap安装Certbot:

sudo yum remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

3. 手动使用Certbot 获取证书

宝塔系统的Nginx配置文件存放在/www/server/nginx/conf,默认情况下Certbot的Nginx插件无法找到nginx.conf配置文件,做个软连接让Certbot能找到nginx.conf文件

sudo ln -s /www/server/nginx/conf /etc/nginx

手动运行获取证书命令

certbot run -a manual -i nginx -d example.com

把其中的example.com换成自己的域名,Certbot会为您生一个密钥,并提示把该密钥放到网站的/www/wwwroot/example.com/.well-known/acme-challenge目录下,确保http://example.com/.well-known/acme-challenge/McVrtxbb6vdx6tSCnULPgNxAhcyKjDpld-a2j_abcd能访问,然后按回车键让Certbot完成证书注册与配置,完成后会有提示信息。





4. 查看结果

进入宝塔系统,打开网站的配置窗口,SSL选项卡,就能看到已为您自动生成Let’s Encrypt免费证书

把配置文件/etc/letsencrypt/renewal/xxx.conf 中的authenticator改为nginx
authenticator = nginx

启用crontab

30 2 * * * /usr/local/bin/certbot-auto renew >> /www/server/panel/logs/certbot.log

近期文章

  • Dify1.3.1安装
  • Gopro 驱动下载
  • Popular models download website
  • Stable diffusion enable remote access
  • Ollama remote access

近期评论

    归档

    • 2025 年 5 月
    • 2025 年 3 月
    • 2025 年 2 月
    • 2024 年 3 月
    • 2023 年 10 月
    • 2023 年 5 月
    • 2023 年 4 月
    • 2022 年 11 月
    • 2022 年 9 月
    • 2022 年 5 月
    • 2022 年 4 月
    • 2022 年 3 月
    • 2022 年 2 月
    • 2022 年 1 月
    • 2021 年 10 月
    • 2021 年 9 月
    • 2021 年 5 月
    • 2020 年 7 月
    • 2020 年 6 月
    • 2020 年 5 月
    • 2020 年 4 月
    • 2020 年 3 月
    • 2019 年 11 月
    • 2019 年 10 月
    • 2018 年 9 月
    • 2018 年 6 月
    • 2018 年 5 月
    • 2018 年 2 月
    • 2017 年 8 月
    • 2016 年 4 月

    分类

    • AI
    • Android
    • Angular
    • Apple Hardware
    • C++
    • Docker
    • Doctine
    • ELK
    • English
    • Hadoop
    • Hbase
    • IDE&Tools
    • Ionic2
    • Javascript
    • jQuery
    • Kubernetes
    • Mac
    • PHP
    • Program
    • Scala
    • Shell
    • SQL
    • Symfony
    • Web
    • Wordpress
    • 一行命令

    其他操作

    • 登录
    • 条目 feed
    • 评论 feed
    • WordPress.org
    ©2025 HE'S BLOG | Powered by WordPress and Superb Themes!