📚
wordpress DB 復元して 別サーバーで表示
前提
DBは復元してあります。
復元方法記事
wordpressに必要なものに関してのインストールは省きます。
手順
今回は mariadb だったので、 Apacheと一緒に起動。
systemctl start mariadb
systmectl start httpd
起動も確認しておきましょう。
IPアドレスでアクセスすると、Wordpressからユーザー名や、DB名などが聞かれるので
いつも設定ファイルの書き換えを行います。
define( 'DB_NAME', 'worspressdbname' );
/** MySQL database username */
define( 'DB_USER', 'wordpres-user' );
/** MySQL database password */
define( 'DB_PASSWORD', 'wordpresspassword' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
DBの設定は復元の時点でやったことにしておきます。
もう一回IPアドレスでアクセスし、wordpressの設定を行えば、別サーバーに移管ができるのですが
自分がアクセスしたときは、ずっと表示がされませんでした。
原因はDB上に登録してある、IPアドレスの書いてあるURLが、持ってきた先のIPアドレスと違うから。
それの再設定もします。
> select * from wp_options where option_name = 'siteurl';
+-----------+-------------+-------------------------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+-------------------------------+----------+
| 1 | siteurl | http://(現在登録のIPアドレス)/wordpress | yes |
+-----------+-------------+-------------------------------+----------+
> update wp_options set option_value = 'http://(新しいIPアドレス)/wordpress' where option_name = 'siteurl';
> select * from wp_options where option_name = 'siteurl';
+-----------+-------------+------------------------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+------------------------------+----------+
| 1 | siteurl | http://(現在登録のIPアドレス)/wordpress | yes |
+-----------+-------------+------------------------------+----------+
これをやれば晴れて見ることができました。
Discussion