#按照官网的要求安装snapd
##Install snapd on rocky linux

1
2
3
4
5
6
7
8
9
10
11
12
$ sudo dnf install epel-release
$ sudo dnf upgrade
$ sudo dnf install snapd
#enable by systemd
Once installed, the systemd unit that manages the main snap communication socket needs to be enabled:

$ sudo systemctl enable --now snapd.socket

To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap:

$ sudo ln -s /var/lib/snapd/snap /snap

#正式安装certbot
##如果有其他版本的,先卸载其他的 yum remove certbot

1
2
sudo snap install --classic certbot #如果出错,来一次sudo dnf reinstall snapd
sudo ln -s /snap/bin/certbot /usr/bin/certbot

本机使用的nginx,在这步命令之前,先保证nginx 的server_name 为需要解析的域名,并且将a记录指向这里的server_name,

@ 指向IP地址,表示joge.top
指向ip地址,表示.joge.top
另外本机使用的是nginx + hexo实现,hexo的默认端口是4000,所以需要用nginx代理下4000到80端口
在location下面,写上proxy_pass http://localhost:4000

1
server_name  joge.top www.joge.top; 

##开始安装,按照提示一步步完成安装。

1
2
sudo certbot --nginx

#测试自动更新,生成一些定时更新的设置

1
sudo certbot renew --dry-run

#重启nginx

1
sudo nginx -s reload

#至此OK.