今回の移行手順を簡単に紹介。
移行手順(MySQL+Apache HTTPD)
- 新サーバーにApache HTTPD,letsencrypt,MySQL,PHP(最低限php-mysqlndモジュールは必須)を導入
- 旧サーバーのMySQLのWordPress用DBをmysqldumpでバックアップファイルをエクスポート
mysqldump -u “ユーザー名” [-p ] “WordPress用DB名” > “バックアップファイル名” - 新サーバーのMySQLにWordPress用DBを作成。アクセスユーザ-も作成し、権限を与える。
- 新サーバーのMySQLのWordPress用DBに1.で作成したバックアップファイルをインポート
mysql -u “ユーザー名” [-p] “WordPressDB名” < “バックアップファイル名” - WordPress最新版を展開。
この際、所有者をapache:apacheとしないと、更新やプラグインなどの取得時にftpの認証画面が表示されてしまうので注意。
※最新版でなくて、前サーバーの<wordpressフォルダ>内容をそのままコピーでも良いのかも - WordPress下のwp-config-sample.phpをwp-config.phpにリネームするかコピーする。
- wp-config.phpの下記の部分を現行システムの物に書き換える。
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** Database username */
define( 'DB_USER', 'username_here' );
/** Database password */
define( 'DB_PASSWORD', 'password_here' );
/** Database 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', '' );
/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**#@-*/
上記のAUTH_KEY以下はPHPコメントにもあるとおり、https://api.wordpress.org/secret-key/1.1/salt/から取得するのが簡単。
この後、管理者としてサイトにアクセスし、旧サーバーで使用していた、themaやplug-in等を追加。(以前の内容をそのままコピーしていたら、要らないのかも)
<wordpressフォルダ>/wp-content/uploadsに前サーバーuploadsの内容をコピー。
(ここも上記と同様)
また、サイトヘルスステータス等を見て、必要なphpモジュール等をインストール。
今回行なったのはこんな感じ。