Certbot 是一個自動化獲取和部署 Let’s Encrypt SSL/TLS 證書的工具
在 CentOS 上安裝 Certbot,首先需要確保已經安裝了 EPEL 和 certbot-apache 或 certbot-nginx 軟件包??梢允褂靡韵旅畎惭b:
sudo yum install epel-release
sudo yum install certbot-apache
或者
sudo yum install epel-release
sudo yum install certbot-nginx
使用 Certbot 獲取證書非常簡單。只需運行以下命令,將 yourdomain.com 替換為你的域名:
對于 Apache:
sudo certbot --apache
對于 Nginx:
sudo certbot --nginx
Certbot 將自動檢測你的 Web 服務器類型并執行相應的操作。按照提示完成證書的獲取和配置過程。
獲取證書后,可以使用以下命令驗證證書是否已經正確安裝:
sudo certbot check
Let’s Encrypt 的 SSL/TLS 證書有效期為 90 天。為了確保網站始終使用有效的證書,可以設置 Certbot 自動更新證書。運行以下命令,將 yourdomain.com 替換為你的域名:
對于 Apache:
sudo certbot --apache --renew-hook "/path/to/your/renew_hook.sh"
對于 Nginx:
sudo certbot --nginx --renew-hook "/path/to/your/renew_hook.sh"
這里,/path/to/your/renew_hook.sh 是一個腳本文件,用于在證書更新時執行相應的操作。你可以根據需要創建和修改這個腳本。
現在,你已經成功獲取并配置了 Let’s Encrypt 證書。你的網站將使用 HTTPS 進行加密通信。