サイトのssl化の手順

サイトのssl化の手順 覚書

let’s encrypt の更新はこちら

さくらのレンタルサーバー かつ wordpress 利用の場合

—————————————————————————————–

1.さくらのサーバーコントロールから無料SSL証明書を発行

2.Really Simple SSL をインストールして実行

さくらインターネット提供のプラグインも存在するが php のバージョンが違ったので Really Simple SSL をインストールした

参考サイト
https://zenlogic.jp/aossl/operation/wp-plugin/

3.google の Search Console と analytics の設定を変更する

https://candy.fun-net.biz/https-google-search-console-analytics/

—————————————————————————————–

さくらのレンタルサーバー かつ wordpress でないの場合

—————————————————————————————–
1さくらのレンタルサーバー wordpress でない場合

1.さくらのサーバーコントロールから無料SSL証明書を発行

2.CSS や 画像ファイル の URL を http → https に変更

SSL証明書を発行後に https のアドレスでページにアクセスすると表示はされるもののレイアウトが崩れる。このとき chrome のアドレスバーには鍵マークでなく「!」になっていた。原因は http CSS や画像ファイルを http で読み込んでいるのが原因なので https に書き換える。

3.htaccess で http → https の301リダイレクトを設定

htaccess に記述
—————————————————
RewriteEngine on
RewriteCond %{HTTPS} off //RewriteRuleが実行される条件。直後の RewriteRule のみが対象
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
—————————————————

4.google の Search Console と analytics の設定を変更する

https://candy.fun-net.biz/https-google-search-console-analytics/
—————————————————————————————–

さくらのvpsの場合

基本的にここ↓を参考にする
https://knowledge.sakura.ad.jp/10534/

しかしリンク先の解説は CentOS7 を対象としているが、自分が利用しているのは CentOS6.9なのでちょいちょい違うので注意。

ファイアウォールのコマンドは CentOS6.9を利用しているので firewall-cmd ではなく iptables を使う。

iptables の起動状態を確認
————————————-
/etc/init.d/iptables status
————————————-

ssl で利用する 443 ポートが開いていることを確認
————————————-
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443
————————————-

Let’s Encrypt を利用するには Certbot を利用する必要があるのでインストール

コマンド
————————————-
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto
————————————-

その後指示に従う。

途中で、http でのアクセスを https にリダイレクトするか聞かれるが、手動(htaccess)でリダイレクトしたいので「1」を選択

————————————-

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 for
new sites, or if you’re confident your site works on HTTPS. You can undo this
change by editing your web server’s configuration.
——————————————————————————-
————————————-

インストールが完了したら httpd を再起動

————————————-
service httpd start
————————————-

https でアクセスできるか確認する

二つ契約しているさくらのVPSの片一方がうまく SSL化できなかった。

適用するドメインを選択するこの場面で現在利用してないドメインも選択したのが原因だと思われる。

Which names would you like to activate HTTPS for?
——————————————————————————-
1: one,example.com
1: two,example.com
1: three,example.com
1: four,example.com
1: five,example.com
1: six,example.com
1: seven,example.com
1: eight,example.com
——————————————————————————-

エラーが出てきちんと完了しない場合は、関連ファイルを全部消して再度実行するといい。
削除したファイル1
—————————————————-
rm -rf /opt/eff.org/certbot
rm -rf /etc/letsencrypt
—————————————————-

削除したファイル2
certbot-auto というファイルがいくつかのディレクトリ内にできているのですべて削除
探す場所
—————————————————-
cd /opt/eff.org/
cd /etc/
cd /etc/httpd/conf.d/
—————————————————-

不要ファイルをすべて削除したら再度実行。

コマンド
————————————-
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto
————————————-

タイトルとURLをコピーしました