WordPress移行手順(雑)

今回の移行手順を簡単に紹介。

移行手順(MySQL+Apache HTTPD)

  1. 新サーバーにApache HTTPD,letsencrypt,MySQL,PHP(最低限php-mysqlndモジュールは必須)を導入
  2. 旧サーバーのMySQLのWordPress用DBをmysqldumpでバックアップファイルをエクスポート
    mysqldump -u “ユーザー名” [-p ] “WordPress用DB名” > “バックアップファイル名”
  3. 新サーバーのMySQLにWordPress用DBを作成。アクセスユーザ-も作成し、権限を与える。
  4. 新サーバーのMySQLのWordPress用DBに1.で作成したバックアップファイルをインポート
    mysql -u “ユーザー名” [-p] “WordPressDB名” < “バックアップファイル名”
  5. WordPress最新版を展開。
    この際、所有者をapache:apacheとしないと、更新やプラグインなどの取得時にftpの認証画面が表示されてしまうので注意。
    ※最新版でなくて、前サーバーの<wordpressフォルダ>内容をそのままコピーでも良いのかも
  6. WordPress下のwp-config-sample.phpをwp-config.phpにリネームするかコピーする。
  7. 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モジュール等をインストール。

    今回行なったのはこんな感じ。

    たけぞう について

    ソフトウェア開発会社(ITと言う言葉は大嫌い)で働く、元技術者。 未だに、社内システム位は作ってますが・・・ プログラミング言語はC#が好き。 好きなことだけ拾って投稿しているので、内容にはあまり期待しないでねw
    カテゴリー: 保守・運用, 日記的なもの パーマリンク

    コメントを残す

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

    このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください