LoginSignup
1
0

More than 5 years have passed since last update.

WordPress環境のIPアドレスが変わってしまったときの対処法

Posted at

背景

AWS(EC2)上に構築したWordPress環境があった。ElasticIPを関連付けていなかったため、ElasticIPを関連付けようと、作業を行った。作業を行った結果、グローバルIPが変更されてしまった。ために、次の2つが設定と合わなくなってしまい、WordPress環境が開かなくなってしまった。

  • WordPressアドレス
  • サイトアドレス

やったこと

今回のパターンはよくあることらしいので次の記事を参考にした。
https://www.nishi2002.com/4207.html

wp-config.phpに次の2項目を追加した

define('WP_SITEURL', 'http://***.***.***.***/wp'); // WordPressアドレス
define('WP_HOME', 'http://***.***.***.***.***'); // サイトアドレス

今回利用しているWordPress環境は、RDSにて外部DBを持っているため、この変更だけではWordPressの設定値を書き換えることができない。(外部DBがない場合はこれだけで大丈夫なはず?未確認)

そこで、RDS環境に直接入り、UPDATEをかけた。

select * from wp_options limit 2;
+-----------+-------------+--------------------------+----------+
| option_id | option_name | option_value             | autoload |
+-----------+-------------+--------------------------+----------+
|         1 | siteurl     | http://xxx.xxx.xxx.xxx/wp | yes     |
|         2 | home        | http://xxx.xxx.xxx.xxx    | yes     |
+-----------+-------------+--------------------------+----------+

> update wp_options set option_value = 'http://***.***.***' where option_name = 'home';

> update wp_options set option_value = 'http://***.***.***' where option_name = 'home';

注意点

http:// から記載しないと、相対パスになってしまうので注意。これで何回かハマってしまった。。。

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