Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active February 3, 2026 10:10
Show Gist options
  • Select an option

  • Save yano3nora/82df1bc7c2fc79a86cfafdebe4951987 to your computer and use it in GitHub Desktop.

Select an option

Save yano3nora/82df1bc7c2fc79a86cfafdebe4951987 to your computer and use it in GitHub Desktop.
acme.sh + let's encrypt

acme.sh

https://github.com/acmesh-official/acme.sh

  • 古い linux 向けの証明書発行/自動更新ツール
  • Let's Encrypt にも対応してる
  • Amazon Linux 2 なら certbot のほうがいい
    • けど古い Amazon Linux 1 ならこっちのがすんなり入れられる
  • 設計コンセプトとしては cron で更新する感じらしい

Install

$ curl https://get.acme.sh | sh
$ source ~/.bashrc 2>/dev/null || true

# shell 再起動して
$ acme.sh --version # v3.1.3

# Let's Encrypt を利用
$ acme.sh --set-default-ca --server letsencrypt

Generate Certificate for Apache

https://qiita.com/rewish/items/e8ddf1846a71a01d86ee

$ export YOUR_DOMAIN=example.com
$ acme.sh --issue --apache -d $YOUR_DOMAIN

# サブドメインもいれるならこんな
# acme.sh --issue --apache \
#   -d example.com \
#   -d hoge.example.com

# apache 系ならだいたい ↓ に cert 保管するので、なければ作成する
$ mkdir -p /etc/pki/tls/private /etc/pki/tls/certs
$ chmod 700 /etc/pki/tls/private

# ↑ パスに証明書をインストール
$ acme.sh --install-cert -d ${YOUR_DOMAIN} \
  --key-file /etc/pki/tls/private/${YOUR_DOMAIN}.key \
  --fullchain-file /etc/pki/tls/certs/${YOUR_DOMAIN}.fullchain.pem \
  --reloadcmd "service httpd reload"

# cert 参照先を書き換え (だいたい ↓ パスのはず)
$ cp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.backup2026
$ vi /etc/httpd/conf.d/ssl.conf
# SSLCertificateFile /etc/pki/tls/certs/${YOUR_DOMAIN}.fullchain.pem
# SSLCertificateKeyFile /etc/pki/tls/private/${YOUR_DOMAIN}.key

# ↑ 設定の反映
$ service httpd configtest
$ service httpd reload

# acme.sh が cron 設定を自動的に入れてくれてるか確認
$ crontab -l | grep acme.sh || true

# cron で自動更新が走るかをテスト
$ acme.sh --renew -d ${YOUR_DOMAIN} --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment