當前位置:
首頁 > 知識 > centos7-快速生成https證書

centos7-快速生成https證書

簡介

cerbot是一個讓你的網站自動部署Let"s Encrypt頒發的免費數字證書,使得你的網站支持https。

安裝

在epel-release上面就有對應的安裝包,直接使用yum安裝就可以了。

yum -y install epel-release

yum -y install certbot.noarch

配置

如果使用yum安裝的nginx或者apache,可以直接執行cerbot,程序會自動找到web容器進行添加證書,如果是自己編譯的,就需要手動生成證書,再進行配置。

1、rpm包的nginx

yum -y install nginx

2、配置證書

cerbot run

手動配置

生成證書

certbot certonly

Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

1: Spin up a temporary webserver (standalone)

2: Place files in webroot directory (webroot)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Select the appropriate number [1-2] then [enter] (press "c" to cancel): opcai.top

#這裡選擇配置webroot的路徑,或者指定一個域名,如果網站已經建成就直接輸入域名就可以自動生成了

Cert not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn"t close to expiry.

(ref: /etc/letsencrypt/renewal/opcai.top.conf)

證書成成位置

/etc/letsencrypt/live/opcai.top/

證書:cert.pem

私鑰:privkey.pem

配置到對應的web容器配置文件即可。

自動更新證書

證書只有三個月的期限,可以開啟定時任務自動更新:

systemctl enable certbot-renew.timer

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!


請您繼續閱讀更多來自 linux運維菜 的精彩文章: