【WordPress】Amazon LightsailとCertbotでHTTPS化に挑戦してみた
約 4 分
目次
概要
AWS Lightsail (リンク)とCertbotでHTTPS化に挑戦してみた。 ネットに散らばっている情報を元に"letsencrypt"や"sslなう。"を使ってみたが上手くいかなかった(bitnaminのせいか....)。 改めてCertbotを使ってみたら、すんなりできたので書くことにした。
環境
あらかじめ、WordPressがインストールされている状態で、また以下が設定/構築されている
- ubuntu16.04
- ポート80、443
- DNSが名前解決できる
前準備
sudo apt-get update
sudo apt-get upgradeå
sudo apt-get install git
Certbotのインストール
gitからCertbotを落としてきて10秒くらい待ちます。
cd /usr/local
git clone https://github.com/certbot/certbot
cd certbot
証明書取得
現在のディレクトリでこのコマンドを実行する
./certbot-auto certonly --webroot -w /opt/bitnami/apps/wordpress/htdocs/ -d ドメイン
上手くいくとこのようなメッセージが出る
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/ドメイン名/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/ドメイン名/privkey.pem Your cert will expire on 2018-05-04. To obtain a new or tweaked version of this certificate in the future, simply run certbot-auto again. To non-interactively renew *all* of your certificates, run "certbot-auto renew" - If you like Certbot, please consider supporting our work by:Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
あとは細かい設定を行い、apacheを再起動します。
sudo cp /etc/letsencrypt/live/ドメイン名/fullchain.pem /opt/bitnami/apache2/conf/server.crt
sudo cp /etc/letsencrypt/live/ドメイン名/privkey.pem /opt/bitnami/apache2/conf/server.key
sudo /opt/bitnami/ctlscript.sh restart apache
無事HTTPS化されると思います。
おまけ1 | 常時SSL
httpにアクセスされた際にhttpsへリダイレクトする
sudo vim /opt/bitnami/apache2/conf/bitnami/bitnami.conf
VirtualHostの項目を編集する
<virtualhost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
</virtualhost>
apache再起動
sudo /opt/bitnami/ctlscript.sh restart apache
参考
おすすめの記事
最新の記事
よく読まれている記事
タグから探す
- javascript130
- typescript67
- node.js54
- linux54
- 画像処理48
- amazon-aws48
- アルゴリズム37
- canvas35
- html529
- 画像処理100本ノック27
- php24
- centos24
- python22
- 競技プログラミング21
- mac21
- mysql20
- opencv17
- 雑談16
- 機械学習16
- docker16
- wordpress15
- atcoder14
- apache12
- データベース12
- amazon-s312
- red-hat12
- prisma12
- ubuntu11
- github10
- git10
- react10
- mariadb10
- vue.js9
- next.js9
- aws-cdk9
- css38
- 可視化8
- 小ネタ8
- nestjs8
- amazon-lightsail7
- ブログ6
- cms6
- oracle6
- perl6
- gitlab6
- iam5
- amazon-ec25
- 資格試験5
- aws-amplify5
- curl4