ドメイン変更した

というわけでドメイン変更をしました
サブドメインのほうは別用途で使っているのでそちらも残しつつWordPressのみを新ドメインに対応させます

1.nginxのconfファイルの修正

nginxのconfファイルを修正します。
修正前はこんな感じでした

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
server {
  listen 443 ssl http2;
  server_name rohisama.ma-hiro.com www.rohisama.ma-hiro.com;
  #server_name ma-hiro.com www.ma-hiro.com;
 
  client_max_body_size 20M;
 
  root /var/www/wordpress;
  index index.php;
 
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
 
  ssl_certificate           /etc/letsencrypt/live/rohisama.ma-hiro.com/fullchain.pem;
  ssl_certificate_key       /etc/letsencrypt/live/rohisama.ma-hiro.com/privkey.pem;
  ssl_trusted_certificate   /etc/letsencrypt/live/rohisama.ma-hiro.com/chain.pem;
  ssl_dhparam               /etc/letsencrypt/live/rohisama.ma-hiro.com/dhparam.pem;
 
  #ssl_certificate           /etc/letsencrypt/live/ma-hiro.com/fullchain.pem;
  #ssl_certificate_key       /etc/letsencrypt/live/ma-hiro.com/privkey.pem;
  #ssl_trusted_certificate   /etc/letsencrypt/live/ma-hiro.com/chain.pem;
  #ssl_dhparam               /etc/letsencrypt/live/ma-hiro.com/dhparam.pem;
 
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:50m;
  ssl_session_tickets off;
  ssl_stapling on;
  ssl_stapling_verify on;
  resolver 8.8.4.4 8.8.8.8 valid=300s;
  resolver_timeout 10s;
 
  add_header Strict-Transport-Security max-age=15552000;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
 
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }
}

修正後はこんな感じ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
server {
  listen 443 ssl http2;
  server_name ma-hiro.com www.ma-hiro.com;
  client_max_body_size 20M;
 
  root /var/www/wordpress;
  index index.php;
 
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
 
  ssl_certificate           /etc/letsencrypt/live/ma-hiro.com/fullchain.pem;
  ssl_certificate_key       /etc/letsencrypt/live/ma-hiro.com/privkey.pem;
  ssl_trusted_certificate   /etc/letsencrypt/live/ma-hiro.com/chain.pem;
  ssl_dhparam               /etc/letsencrypt/live/ma-hiro.com/dhparam.pem;
 
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:50m;
  ssl_session_tickets off;
  ssl_stapling on;
  ssl_stapling_verify on;
  resolver 8.8.4.4 8.8.8.8 valid=300s;
  resolver_timeout 10s;
 
  add_header Strict-Transport-Security max-age=15552000;
  #location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
  #  try_files $uri $uri/index.html;
  #}
 
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
 
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }
}
server {
        server_name rohisama.ma-hiro.com;
        listen 80;
        listen [::]:80;
 
        # SSL configuration
        #
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl_certificate     /etc/letsencrypt/live/rohisama.ma-hiro.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/rohisama.ma-hiro.com/privkey.pem;
 
        if ($scheme = http) {
            return 301 https://$host$request_uri;
        }
        include /etc/nginx/sites-enabled/rohisama/*;
        root /var/www/html;
 
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;
 
 
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/index.html;
        }
}

修正後はサーバのコンソールからnginxをリロードさせる
コマンドはnginx -s reload または systemctl restart nginx
なんでかわからないけど要素の順番入れ替えるとrohisama.ma-hiro.comは繋がるがma-hiro.comがつながらない現象に陥った・・・
とりあえず今は動いてるからよし・・・

2.WordPressアドレスの変更

一旦ページが表示されるようにはなったが別記事参照しようとすると元のドメインにリンク飛んでしまうため管理者ログイン後ダッシュボード→設定からWordPressアドレスを修正する

サイト引っ越しする場合と一緒かな。とりあえずドメイン変更は完了です。よかった

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA