前提

OS: CentOS(異なるOSの場合適宜読み替えて下さい)

Webサーバー: Apache2

ドキュメントルート: /var/www/html (異なる場合は適宜読み替えて下さい)

 

インストール

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

 

証明書の発行

certbot certonly --webroot -w /var/www/html/ -d <domain name>

以下の入力を促されます。

・証明書切れの通知アドレス

・証明書への同意

・Electronic Frontier Foundation からの定期購読メール送信可否

 

/etc/httpd/conf.d/ssl.conf の設定

SSLCertificateFile /etc/letsencrypt/live/<domain_name>/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<domain_name>/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/<domain_name>/chain.pem

 

SSLポート解放

firewall-cmd --add-port=443/tcp --zone=public
firewall-cmd --add-port=443/tcp --zone=public --permanent

 

常時SSL化

/var/www/html/.htaccess を以下の内容で作成

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

 

.htaccessを有効にするため /etc/httpd/conf/httpd.conf を修正

<Directory “/var/www/html”>
AllowOverride All
</Directory>

 

apacheの再起動をして完了です。