LoginSignup
31
41

More than 5 years have passed since last update.

Wordmoveの基本操作

Last updated at Posted at 2017-12-27

Wordmoveとは

  • Wordpressのデータをサーバー〜ローカル間で転送できるツール

ex: https://github.com/welaika/wordmove

前提

  • Mac / 10.12.4 Sierraで作業
  • Virtual Box, Vagrantをインストール済
  • VCCWでWordpressをインストール済

設定

設定ファイル

プロジェクトルートにある。

# VCCWでWordpressをインストール済
.
├── LICENSE
├── Movefile.yml # これが設定ファイル
├── README.md
├── Vagrantfile
├── ansible.cfg
├── provision
├── wordpress
├── wp-cli
└── wp-cli.yml

内容

※ YAMLのためインデントがずれないように注意する
 ref: YAML Init(YAMLのlint)

local:
  vhost: "ローカル環境のドメイン"
  wordpress_path: "ルートからWordpressディレクトリへのパス"

  database:
    name: "wordpress"
    user: "wordpress"
    password: "wordpress"
    host: "localhost"
    charset: "utf8"

  # paths: # you can customize wordpress internal paths
  #   wp_config: "wp-config-custom.php"
  #   wp_content: "wp-content"
  #   uploads: "wp-content/uploads"
  #   plugins: "wp-content/plugins"
  #   mu_plugins: "wp-content/mu-plugins"
  #   themes: "wp-content/themes"
  #   languages: "wp-content/languages"

production:
  vhost: "本番環境のドメイン"
  wordpress_path: "Wordpressディレクトリへのパス" # ルートからの絶対パス

  database:
    name: "データベース名"
    user: "ユーザー名"
    password: "パスワード"
    host: "ホスト"
    port: "3308" # サーバーの内容に合わせる
    mysqldump_options: "--max_allowed_packet=50MB" # SSHでのみ有効

  exclude:
    - ".git/"
    - ".gitignore"
    - ".sass-cache/"
    - "bin/"
    - "tmp/*"
    - "Gemfile*"
    - "movefile.yml"
    - "wp-config.php"
    - "wp-content/*.sql"

  ssh:
    host: "SSHホスト"
    user: "ユーザー名"
    port: 22 # オプショナル
    rsync_options: "--verbose" # オプショナル

サブディレクトリにWordpressをインストールした場合

pathsにサブディレクトリを追記する。

# Movefile.yml
# サブディレクトリにWordpressをインストールした場合のディレクトリパス指定

  paths:
    wp_config: "admin/wp-config.php"
    wp_content: "admin/wp-content"
    uploads: "admin/wp-content/uploads"
    plugins: "admin/wp-content/plugins"
    mu_plugins: "admin/wp-content/mu-plugins"
    themes: "admin/wp-content/themes"
    languages: "admin/wp-content/languages"

使う

  1. vagrant up(起動)
  2. vagrant ssh(SSHで接続)
  3. cd /vagrant~/vagrantディレクトリに移動)
  4. wordmove pushまたはwordmove pull

pull(リモートからローカルへ)

# ファイル全てを本番環境(リモート)へpull
$ wordmove pull -e production --all`

push(ローカルからリモートへ)

# ファイル全てを本番環境(リモート)へpush
$ wordmove push  -e production --all`

オプションコマンド

--all # ファイル全部
-w    # `/wp-content/`ディレクトリ(除外したファイル以外)のみ
-u    # `/wp-content/upload/`ディレクトリのみ
-t    # `/wp-content/theme/`のみ
-p    # `/wp-content/plugins/`のみ
-l    # `/wp-content/language/`のみ
-d    # データベースファイルのみ
-v    # [TBD] verbose
-s    # dry runモードで実行、実際にはファイル転送されない
-e    # 環境(push先・pull元)を指定
-c    # `wp-config.php`のみ
-h    # wordmoveの使い方

-v

メッセージの詳細表示。

[TBD]

-s

いわゆる dry runモード。リモートのサーバの接続チェックなどに利用します。

転送確認する時などに使う。

-e

オプションの後にmovefile.ymlで設定した環境の名前を指定できる。
デフォルトにはlocalproductionがある。

その他

ssh接続できない場合

対応

鍵情報を登録する。

# 1. ssh接続
$ vagrant ssh

# 2. ルート権限になる
$ sudo su -

# 3-a. /home/vagrant/.sshに移動
[root@ユーザー名] cd /home/vagrant/.ssh

# 3-b. /home/vagrant/.sshが無い場合はディレクトリを作成
[root@ユーザー名] ls -a /home/vagrant
[root@ユーザー名] mkdir .ssh
[root@ユーザー名] cd .ssh

# 4-1. 鍵ファイルを追加する
[root@ユーザー名] vi 鍵ファイル名 (&内容を追加する)

# 4-2. ファイルパーミッションを変更
[root@ユーザー名] chmod 600 鍵ファイル名

# 5. configファイルを追加する
[root@ユーザー名] vi config (&内容を追加する)

# 6. 終了
[root@ユーザー名] exit

VCCW (v3)の場合

VCCW (v3)でFTPでWordmoveする場合、lftpをインストールしておかないとlftp: not foundとなる。

対応

lftpをインストールする。

# 1. $ vagrant ssh # ssh接続
# 2. $ sudo su -   # ルート権限になる

# 3. インストール前の確認
#    lftp: not foundと出たらインストールが必要
[root@ ~] lftp -v

# 4. インストール
[root@ ~] apt-get install -y lftp

# 5. インストール後の確認
#    以下が表示されればインストール完了
[root@ ~] dpkg -l | grep lftp
ii  lftp                               4.6.3a-1build2                      amd64        Sophisticated command-line FTP/HTTP/BitTorrent client programs

# 6. 終了
[root@ ~] exit

ref: https://github.com/welaika/wordmove#ftp

SQL syntaxエラーが出る場合

  • このエラーはVCCW (v2)で確認されたものですが念のため記載します
  • また、このエラー内容でのWordmoveはバージョン1.2.0ですが、VCCW (v2)の場合はバージョンを上げることをおすすめします

エラー内容

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Warning: mysqli::\_\_construct(): (HY000/2002): Connection refused ' at line1/usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/wordmove-1.2.0/lib/wordmove/deployer/base.rb:147:in `run': Return code reports an error (RuntimeError)
 ・
 ・
 ・

対応

ファイルのパーミッションが正しくない(サーバーとローカルのバーミッションが一致していない)かもしれないため、

  • サーバーデフォルトのパーミッションへ変更する
31
41
1

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
31
41