LoginSignup
0
0

More than 3 years have passed since last update.

CentOS7のSSL対応(Apache)

Last updated at Posted at 2020-07-16

こすられまくっている内容とは知りつつも、導入できたのでまとめずにはいられない。

1. mod_sslを導入

以下のコマンドで導入します。

yum install -y mod_ssl

インストールできたらhttpdを再起動。

apachectl restart

2. certbotを導入

導入は公式に書いてあります。

certbot --apacheで、正しい入力をしているにも関わらず、以下のようなエラーが出力される場合があります。

Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.

これは仮想ポートの設定がされていないためです。

以下のサイトを参考に/etc/httpd/conf/httpd.confを修正します。

echo 'NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin root@hogehoge
DocumentRoot /var/www/html
ServerName hogehoge
</VirtualHost>' >> /etc/httpd/conf/httpd.conf

hogehogeを自分のサーバードメインに修正するのを忘れずに。

3. sslの設定

certbotの導入後は、/etc/httpd/conf.d/ssl.confを編集する必要があります。(ここ大事)

以下のサイトを参考。

4. cronの設定

証明書の更新を自動化します。

ここでは毎月1日と15日の4時に証明書の更新を行うように設定します。

/etc/crontabを編集します。

00 04 01 * * certbot renew && systemctl restart httpd
00 04 15 * * certbot renew && systemctl restart httpd

以上です。

お疲れさまでした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0