# SLL メモ
# 環境
- centos7
- centos8
# オレオレ証明書作成コマンド
※作成するディレクトリにあらかじめ移動しておくこと
openssl genrsa -out cert.key 2048
openssl req -subj '/CN=common_name.example.com/O=ORGANIZATION/C=JP' -new -key cert.key > cert.csr
openssl x509 -in cert.csr -days 3650 -req -signkey cert.key > cert.crt
# Let's Encrypt 基本設定
git が入ってなければ入れておく
yum -y install git
環境依存情報設定 ※適宜環境に合わせて値を変える
#webサーバのドメイン
mydomain="mydomain.com"
#webサーバのドキュメントルート
documentroot="pjdir"
#連絡先メールアドレス
mymailaddress="ssl.com"
ssl 設定
cd /usr/local
git clone https://github.com/certbot/certbot
/usr/local/certbot/certbot-auto certonly --webroot -w /var/www/$documentroot -d $mydomain -m $mymailaddress --agree-tos -n --expand
既存設定の変更例(オレオレ証明書設定済みの nginx の場合)
sed -i -e "s/\/etc\/nginx\/ssl\/cert.crt/\/etc\/letsencrypt\/live\/$mydomain\/cert.pem/g" /etc/nginx/conf.d/$mydomain.conf
sed -i -e "s/\/etc\/nginx\/ssl\/cert.key/\/etc\/letsencrypt\/live\/$mydomain\/privkey.pem/g" /etc/nginx/conf.d/$mydomain.conf
rm -fR /etc/nginx/ssl
systemctl restart nginx
更新時のコマンド
/usr/local/certbot/certbot-auto renew
systemctl restart nginx