Centos Stream9: Let's Encrypt

投稿日:

ya0601_2022.jpg


Centos Stream 9 に Let's Encrypt

Centos Stream 9 では snapd が使用できません。ということで、対応する迄待つことにしていましたが, pip でインストールできる事が分かりました。以下実行した手順です。

certbot-autoは非推奨になりました。このサイトを参考にしました。

python3.x+pipをインストール


# dnf -y install python39 python39-pip augeas-libs


Version を表示


# python --version

 Python 3.9.9

# pip --version

 pip 21.2.3 from /usr/lib/python3.9/site-packages/pip (python 3.9)


実行専用の環境を作成しcertbot をInstall


# sudo python3 -m venv /opt/certbot

# sudo /opt/certbot/bin/pip install --upgrade pip

# sudo /opt/certbot/bin/pip install certbot certbot-apache

# sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot

# certbot --version

 certbot 1.22.0


自動更新の設定

# SLEEPTIME=$(awk 'BEGIN{srand(); print int(rand()*(3600+1))}'); echo "0 0,12 * * * root sleep $SLEEPTIME && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null

Let's Encrypt のサーバー証明書再取得

 まずは「/etc/letsencrypt/」下の「live」・「archive」内にある「ドメイン名」ディレクトリを削除し、「renewal」内にある「ドメイン名.conf」も削除。

続いて以下のコマンドで証明書を再取得します。


# certbot certonly -webroot -w /var/www/html -d 「ドメイン名」-m 「Mail Address」