1
0

More than 3 years have passed since last update.

ドメインの初期設定とHTTPS化

Posted at

概要

ドメイン初期設定と HTTPS 化 ( さくらの VPS × Let's Encrypt )

サーバの IP を確認

さくらの VPS は、デフォルトでドメインが割り当てられている。

そのため、デフォルト値を使用する。

なお、ドメインは、以下 URL の管理画面における ホスト名 の箇所で確認できる。

サーバのドメイン設定

$ echo ${ホスト名} | sudo tee /etc/hostname
$ sudo reboot

HTTPS 化 ( Let's Encrypt )

設定ファイルの調整

$ cd /etc/apache2/sites-available/
$ sudo cp 000-default.conf ${新設定ファイル}.conf
$ vim ${新設定ファイル}.conf
${新設定ファイル}.conf
- <VirtualHost *:80>
+ <VirtualHost ${ドメイン名}:80>
$ cd /etc/apache2/sites-enabled

$ sudo rm 000-default.conf

$ sudo ln -s ../sites-available/${新設定ファイル}.conf ./

$ sudo service apache2 restart

Let's Encrypt のインストール

$ sudo apt install letsencrypt python-certbot-apache

サーバ証明書を取得

$ sudo letsencrypt --apache
Question Answer
Enter email address 自分のメールアドレス ( 証明書更新時期に連絡あるかも? )
Please read the Terms ... 規約に同意できる場合は、Agree
Would you be willing to share your email address... 任意
Which names would you like to activate https for ? HTTPS 化したいドメインを選択
Please choose whether or not to redirect HTTP traffic to HTTPS 2. Redirect

終了

Let's Encrypt におけるサーバ証明書の有効期限は、90 日間 である。

証明書の更新時は、以下のコマンドを実行すること。

sudo letsencrypt renew

メモ: 無料ドメインの取得

使用期限が 1 年未満となるが、無料ドメインの選択肢が存在する。

1
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
1
0