pkg search certbot
pkg install py39-certbot py39-certbot-apache
cd /usr/local/etc/letsencrypt/live/
certbot certonly –webroot -w /usr/local/www/apache24/data/wordpress -d jcc0413.jg7sfr.mydns.jp
Account registered.
Requesting a certificate for jcc0413.jg7sfr.mydns.jp
Successfully received certificate.
Certificate is saved at: /usr/local/etc/letsencrypt/live/jcc0413.jg7sfr.mydns.j /fullchain.pem
Key is saved at: /usr/local/etc/letsencrypt/live/jcc0413.jg7sfr.mydns.j /privkey.pem
This certificate expires on 2023-12-19.
These files will be updated when the certificate renews.
NEXT STEPS:
The certificate will need to be renewed before it expires. Certbot can automa ically renew the certificate in the background, but you may need to take steps o enable that functionality. See https://certbot.org/renewal-setup for instruct ons.
vi /usr/local/etc/apache24/extra/httpd-ssl.conf
(Includeにも設置してしまうとどちらも読み込まれ設定がおかしくなってしまったのでextraだけにする)
(httpd.confに設定あり)
ServerName jcc0413.jg7sfr.mydns.jp:443
ServerAdmin sfrnoh@gmail.com
SSLCertificateFilea “/usr/local/etc/letsencrypt/live/jcc0413.jg7sfr.mydns.jp/ fullchain.pem”
SSLCertificateKeyFile “/usr/local/etc/letsencrypt/live/jcc0413.jg7sfr.mydns. jp/privkey.pem”
certbot –dry-run renew
echo ‘weekly_certbot_enable=”YES”‘ >> /etc/periodic.conf
cd /usr/local/etc/letsencrypt/renewal-hooks/deploy/
/etc/periodic.confは定期的に実行するらしいので、cronを使わず様子を見ることとする
vi reload_apache24.sh
#!/bin/sh
service `echo $0|sed -e ‘s/.*\/\(.*\)_\(.*\).sh/\2 \1/’`
chmod 755 reload_apache24.sh
FreeBSD 13とApache 2.4とcertbotでLet’s Encrypt! [のふ処|NOFUDOKORO]
こちらのサイトを参考にさせていただいた。
サブドメインの認証を受けた後、サブドメインからメインに移行するための処理(仮
先ずはテスト的に
certbot certonly –force-renew –cert-name jcc0413.jg7sfr.mydns.jp -d jcc0413.jg7sfr.mydns.jp -d jg7sfr.mydns.jp –dry-run
cd /usr/local/etc/letsencrypt/live/
certbot certonly –dry-run –webroot -w /usr/local/www/apache24/data/wordpress -d jcc0413.jg7sfr.mydns.jp -d jg7sfr.mydns.jp
確認
certbot certificates
手順案
1.旧サーバーで認証を失効させる
certbot revoke –cert-path /usr/local/etc/letsencrypt/live/jg7sfr.mydns.jp/fullchain.pem
2.新サーバーで認証を得る
certbot revoke –cert-path /usr/local/etc/letsencrypt/live/jcc0413.jg7sfr.mydns.jp/fullchain.pem
certbot certonly –dry-run –webroot -w /usr/local/www/apache24/data/wordpress -d jg7sfr.mydns.jp
certbot certonly –webroot -w /usr/local/www/apache24/data/wordpress -d jg7sfr.mydns.jp -d jg7sfr.mydns.jp
3.wordpressアドレスとサーバーアドレスをhttps://jg7sfr.mydns.jpに変更(mydns)
管理画面またはphpMyAdminまたはmysqlコマンド
phpMyAdminまたはmysqlコマンドで下記4項目実行
mysql -U *** -p
パスワード入力
use ???db
UPDATE wp_options SET option_value = REPLACE(option_value, ‘https://jcc0413.jg7sfr.mydns.jp’, ‘https://jg7sfr.mydns.jp’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = REPLACE(guid, ‘https://jcc0413.jg7sfr.mydns.jp’,’http://ex-new.com’);
UPDATE wp_posts SET post_content = REPLACE(post_content, ‘https://jcc0413.jg7sfr.mydns.jp’, ‘https://jg7sfr.mydns.jp’);
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,’https://jcc0413.jg7sfr.mydns.jp’,’https://jg7sfr.mydns.jp’);
4.mydns319391で新サーバーのアドレスに変更
この時点で、新旧2台のサーバーにあるmydnsへのアドレス通知設定はコメントアウト
5.mydns子ID削除(時間経過で自動削除)
試しにmydnsのIPだけを新旧ひっくり返して新の.wordpressアドレスとサーバーアドレスを修正しただけではダメでした。
6.httpd.confやhttpd-ssl.confの修正
7.wordpressでobject cacheを利用していればflush(キャッシュ削除)
wp-config.phpを場合によっては修正し対応。
apacheの.htaccessも確認