0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Let'Encryptの更新作業メモ

Last updated at Posted at 2023-09-08

背景

初めてLet'Encryptの更新時期が来て、苦戦するのではないかとおびえていましたが、
意外と簡単にできたので、メモで残したいと思います。

環境

  • Apache2.4
  • CentOS
  • ドメインは取得・設定済み

Apacheの停止

Apacheは一度停止しないとエラーがでるそうです。
サーバー上のターミナルで以下のコマンドを打ってApacheを一旦停止します。

apachectl stop

テスト環境でLet'Encryptをお試し更新

Let's Encryptは厳しめのレート制限があり、エラーなどでミスし続けると一定時間操作できなくなる可能性があるので、末尾に「--dry-run」をつけてテスト環境でお試し。

sudo certbot renew --dry-run

そうすると以下のように出ます。最後にsuccessと出ていれば成功です!

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/(ドメイン名).conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Account registered.
Simulating renewal of an existing certificate for (ドメイン名)
Performing the following challenges:
http-01 challenge for (ドメイン名)
Error while running apachectl graceful.

Job for httpd.service invalid.

Unable to restart apache using ['apachectl', 'graceful']
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/(ドメイン名)/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/(ドメイン名)/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

本番環境で更新

テスト環境でできることを確認したら「--dry-run」を消して本番で実行します。

sudo certbot renew

同じくsuccessと出ていたら成功です!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/(ドメイン名).conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Renewing an existing certificate for (ドメイン名)
Performing the following challenges:
http-01 challenge for (ドメイン名)
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/(ドメイン名)/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded: 
  /etc/letsencrypt/live/(ドメイン名)/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Apacheの再起動

最初に一旦停止したApacheを再起動します。

apachectl restart

ブラウザでアクセスしてできるかどうか確認

ブラウザでアプリケーションにアクセスしてhttpsになっていればOK。

最後に

私もまだ初心者でわからない部分も多くあります。
お気づきの点があれば教えていただければ幸いです!

以下のサイトを参考にしました。
https://it-jog.com/khow/serv/renewletsencrypt

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?