Published on

在 CentOS 8 服务器上安装 Certbot 启用 HTTPS

Authors
  • avatar
    Name
    Leon
    Twitter

https://certbot.eff.org/instructions?ws=nginx&os=centosrhel8

1. 安装snapd

1.1 Adding EPEL to CentOS 8

sudo dnf install epel-release
sudo dnf upgrade

1.2 安装

sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

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

2. Remove certbot-auto and any Certbot OS packages

# 检查系统是否已经安装了 Certbotdnf list installed | grep certbot
# or 在CentOS7上
yum list installed | grep certbot
# If you have any Certbot packages installed using an OS package manager like apt, dnf, or yum, you should remove them before installing the Certbot snap to ensure that when you run the command certbot the snap is used rather than the installation from your OS package manager.
sudo dnf remove certbot
# or
sudo yum remove certbot

3. Install Certbot

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

4. Choose how you'd like to run Certbot

# Either get and install your certificates...
sudo certbot --nginx
# Or, just get a certificate
sudo certbot certonly --nginx

5. Test automatic renewal

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

6.

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.