
CentOS6 Let's Encryptの実装
2024年に入ってから、CentOS6にLet’s Encryptの実装をやらされたので、共有もかねて、Noteに残します。
※私はめんどくさがりなので、基本rootで作業しています。
Python3.6の導入
以下からPython3.6のモジュールをダウンロード
ダウンロードしたモジュールは依存関係から以下を取得しています。
rh-python36-2.0-1.el6.x86_64.rpm
rh-python36-python-3.6.3-3.el6.x86_64.rpm
rh-python36-python-devel-3.6.3-3.el6.x86_64.rpm
rh-python36-python-libs-3.6.3-3.el6.x86_64.rpm
rh-python36-python-pip-9.0.1-2.el6.noarch.rpm
rh-python36-python-setuptools-36.5.0-1.el6.noarch.rpm
rh-python36-python-virtualenv-15.1.0-2.el6.noarch.rpm
rh-python36-runtime-2.0-1.el6.x86_64.rpm
インストール後に環境変数を設定
# scl enable rh-python36 bash
# python -V
Python 3.6.3
証明書を登録・更新するcertbot用のENVファイル作成
# python -m venv /opt/certbot/
Certbotの準備
pipをインストールし、certbotをインストールします。
# /opt/certbot/bin/pip install --upgrade pip
# /opt/certbot/bin/pip install certbot
実行したら、以下エラーが発生しましちょっと時間がかかったので。
Σ( ̄ロ ̄lll)ガーン
This package requires Rust >=1.41.0.
:
Failed to build cryptography
cryptographyのバージョンがダメだったようなので、以下を実行しインストールし解決しました。
# /opt/certbot/bin/pip install certbot cryptography==3.4.1
Certbotを利用しLetsEncryptの証明書設定
以下で証明書を設定。(ウェブサーバの設定は割愛)
# /opt/certbot/bin/certonly --webroot -w /var/www/hogehoge.com/html -d hogehoge.com
で、証明書を取得できたので、ウェブサーバに証明書を設定し、あとは自動更新用のcronを設定し完了です。
# vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# lets Encrypt update
0 0 * * 0 root /opt/certbot/bin/certbot renew 2>&1 | logger -p daemon.info -t LetsEncrypt
終わりに
いまだにCentOS6なんて使うなよ。。。