無料のSSL証明書をインストールする

※2022/04/25追記 無料のSSL証明書をインストールする(Ubuntu 22.04版)を公開。

No-IPドメインでLet’s Encryptの証明書を使うことが出来る。

1.事前確認
・ドメイン名を取得していること(今回はNo-IPを使用する)
・80、443ポートが外部に開放されていること

2.Certbotをインストールする

yum install epel-release
yum install certbot python-certbot-apache

3.証明書取得する

certbot certonly --agree-tos --webroot -w /var/www/html/ -d hoge.no-ip.org

取得に成功した場合、証明書は以下に保存される。

ll /etc/letsencrypt/live/hoge.no-ip.org/

4.Apacheに証明書を設定し再起動する

バージョン2.4.7以前の場合

SSLCertificateFile /etc/letsencrypt/live/hoge.no-ip.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hoge.no-ip.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/hoge.no-ip.org/chain.pem

バージョン2.4.8以降の場合

SSLCertificateFile /etc/letsencrypt/live/hoge.no-ip.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hoge.no-ip.org/privkey.pem
systemctl restart httpd

5.証明書を自動的に更新する

証明書は90日で失効してしまうため、cron.dに以下のスクリプトを置いておく。
有効期限の30日前になると自動的に更新されるので、とりあえず毎日か、毎週実行する様にしておけば良い。

#!/bin/sh

/bin/certbot renew --webroot-path /var/www/html/ --post-hook "systemctl reload httpd"

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください