前回、サーバのDNS設定を変更してアドレスにドメインを入力すると名前解決されるようになりました。
前回の記事
グーグルドメインで取得したドメインをGoogle Cloud Platform、GCPのDNSに設定とその手順
これで普通なら接続確認が出来るんですが、今回取得した.pageと言うドメインには「より安全」と表示があり、「安全な名前空間のドメイン」「roshis.pageに対しては、ウェブサイト公開前にSSL証明書が必要になります。」
とあって、どうも暗号化されたSSLでないと接続ができないような仕組みのようです。
ということでLet’s Encrypt という無料の SSL 証明書を提供しているCA(認証局)から証明書を取得したいと思います。
手順
Google Cloud Platformに接続して左上のナビゲーションメニューからComputer Engin、VMインスタンスを選択し対象のサーバのSSHをクリックする。
debianのバージョンを確認する。
:~$ cat /etc/os-release
PRETTY_NAME=”Debian GNU/Linux 9 (stretch)”NAME=”Debian GNU/Linux”VERSION_ID=”9″VERSION=”9 (stretch)”ID=debianHOME_URL=”https://www.debian.org/”SUPPORT_URL=”https://www.debian.org/support”BUG_REPORT_URL=”https://bugs.debian.org/”
Jessie backportsリポジトリを有効化するために、backports.listのファイルを開く
:~$ sudo nano /etc/apt/sources.list.d/backports.list
最下部に1行追加する
debian8の場合
deb http://ftp.debian.org/debian jessie-backports main
debian9の場合
deb http://ftp.debian.org/debian stretch-backports main

1行追加したら以下のコマンドを入力して終了する。
control + x、Y、enter、で元の画面に戻る。
パッケージリストを更新
:~$ sudo apt update
パッケージを、リポジトリ backports から入手
debian8の場合
$ sudo apt-get install certbot python-certbot-apache -t jessie-backports
debian9の場合
$ sudo apt-get install certbot python-certbot-apache -t stretch-backports
Do you want to continue? [Y/n] Y
SSL証明書の取得
以下を入力
:~$ sudo certbot
以下が表示されるのでaを入力
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
(A)gree/(C)ancel: a
次はキャンペーンの送付みたいなのでnを入力する。
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let’s Encrypt project and the non-profit
organization that develops Certbot? We’d like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
(Y)es/(N)o: n
ドメインの入力
No names were found in your configuration files. Please enter in your domainname(s) (comma and/or space separated) (Enter ‘c’ to cancel): roshis.page
httpをリダイレクトするかどうか
.pageはhttpsしか使えないので2しました。
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.- – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – -1: No redirect – Make no further changes to the webserver configuration.2: Redirect – Make all requests redirect to secure HTTPS access. Choose this fornew sites, or if you’re confident your site works on HTTPS. You can undo thischange by editing your web server’s configuration.- – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – -Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel): 2
WordPressの設定
WordPressに接続して設定の一般設定のWordPress アドレス (URL)、とサイトアドレス (URL)、にアドレス、https://roshis.pageを入力。

下のボタンの変更を保存、をクリックする。
これでブラウザにアドレスを入力してサイト画面が表示されれば完了。
参考にさせていただいたサイト
【WordPress移行】Let’s Encryptを使ったSSL対応
その他の記事
