ええ、タイトル通りっすよ。もうっすね、便利過ぎて鼻血出ますw
VCCWが2.0.0になって設定方法が従来のVagrantfileを編集する方法から.ymlファイルを編集する方法に変わったので、手順をおさらいしようと思います。
目次
先ずはvagrant起動まで
- 開発用のディレクトリを作成
任意の場所に開発用のディレクトリを作成。/User/ユーザー名/worksとか。[code]cd /User/user-name/works
mkdir new-vccw[/code] - VCCWをダウンロード
VCCW – A WordPress development environment.よりダウンロード。[code]
cd new-vccw
wget https://github.com/vccw-team/vccw/archive/2.0.0.zip
[/code] - 解凍
[code]unzip 2.0.0.zip[/code]
- vccw-2.0.0ってディレクトリになるから何となくリネーム
[code]mv vccw-2.0.0/ vccw[/code]
- vccw/provisionにあるdefault.ymlをvccw配下へコピー
[code]
cd vccw
cp provision/difault.yml site.yml
[/code] - site.ymlを開いて設定
site.ymlはこんな感じ。 -
[code]
# encoding: utf-8
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2#
# General Settings
#
wp_box: miya0001/vccw
chef_cookbook_path: ./provision#
# Network Settings
#
hostname: wordpress.local
ip: 192.168.33.10#
# WordPress Settings
#
version: latest
lang: en_US
title: Welcome to the VCCW
multisite: false
rewrite_structure: /archives/%post_id%#
# WordPress Path
#
sync_folder: ‘www/wordpress’
document_root: ‘/var/www/vhosts/private.hibou-web.com’
wp_home: ” # Path to the WP_HOME like "wp"
wp_siteurl: ” # Path to the WP_SITEURL like "wp"#
# WordPress User
#
admin_user: admin
admin_pass: admin#
# WordPress Database
#
db_prefix: wp_
db_host: localhost#
# WordPress Default Plugins
# Plugin’s slug or url to the plugin’s slug.
#
plugins:
– dynamic-hostname
– wp-total-hacks
– tinymce-templates#
# WordPress Default Theme
# Theme’s slug or url to the theme’s .zip.
#
theme: ”#
# WordPress Options
#
options:
blogdescription: Hello VCCW.#
# The values of wp-config.php
#
force_ssl_admin: false
wp_debug: true
savequeries: false#
# Theme unit testing
#
theme_unit_test: false
theme_unit_test_uri: https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml
# theme_unit_test_uri: https://raw.githubusercontent.com/jawordpressorg/theme-test-data-ja/master/wordpress-theme-test-date-ja.xml#
# DB will be reset when provision
#
reset_db_on_provision: true
[/code]適宜編集。Vagrantfileよりもスッキリしててわかりやすいイメージっす 😀
書き換えてみた↓↓[code]
# encoding: utf-8
# vim: ft=ruby expandtab shiftwidth=2 tabstop=2#
# General Settings
#
wp_box: miya0001/vccw
chef_cookbook_path: ./provision#
# Network Settings
#
hostname: wordpress.local
ip: 192.168.66.66#
# WordPress Settings
#
version: latest
lang: ja
title: VCCWテスト
multisite: false
rewrite_structure: /archives/%post_id%#
# WordPress Path
#
sync_folder: ‘www/wordpress’
document_root: ‘/var/www/vhosts/private.hibou-web.com’
wp_home: ” # Path to the WP_HOME like "wp"
wp_siteurl: ” # Path to the WP_SITEURL like "wp"#
# WordPress User
#
admin_user: admin
admin_pass: admin#
# WordPress Database
#
db_prefix: wp_
db_host: 192.168.66.66#
# WordPress Default Plugins
# Plugin’s slug or url to the plugin’s slug.
#
plugins:
– dynamic-hostname
– wp-total-hacks
– tinymce-templates#
# WordPress Default Theme
# Theme’s slug or url to the theme’s .zip.
#
theme: ”#
# WordPress Options
#
options:
blogdescription: Hello VCCW.#
# The values of wp-config.php
#
force_ssl_admin: false
wp_debug: true
savequeries: false#
# Theme unit testing
#
theme_unit_test: false
theme_unit_test_uri: https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml
# theme_unit_test_uri: https://raw.githubusercontent.com/jawordpressorg/theme-test-data-ja/master/wordpress-theme-test-date-ja.xml#
# DB will be reset when provision
#
reset_db_on_provision: true
[/code]※ YAMLファイルはコロン「:」はハッシュ値を表すようで、コロンの後には半角スペースが要るようです。
※ YAML – Wikipedia
※ Rubyist Magazine – プログラマーのための YAML 入門 (初級編)
書き換えたとき、[code]/opt/vagrant/embedded/lib/ruby/2.0.0/psych.rb:205:in `parse’: (<unknown>): could not find expected ‘:’ while scanning a simple key at line 13 column 1 (Psych::SyntaxError)[/code]
とかでちゃんと教えてくれますが…(^0^;)
- site.ymlを保存してvagrant up!!
約5〜6分ほどで完了しました 😀
絶対早くなってると思う。
次は、WordMoveでローカルとリモートをサクッと 😀
起動完了すると、vccwディレクトリ直下にMovefileができあがっています。
.
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── Movefile
├── README.md
├── Rakefile
├── Vagrantfile
├── provision
│ ├── cookbooks
│ ├── default.yml
│ └── site-cookbooks
├── site.yml
├── spec
│ ├── default
│ └── spec_helper.rb
└── www
└── wordpress
Movefileはこんな感じ。
[code]local:
vhost: "http://wordpress.local"
wordpress_path: "/var/www/vhosts/private.hibou-web.com"
database:
name: "wordpress"
user: "wordpress"
password: "wordpress"
host: "192.168.66.66"
staging:
vhost: "http://example.com"
wordpress_path: "/var/www/your_site" # use an absolute path here
database:
name: "database_name"
user: "user"
password: "password"
host: "localhost"
exclude:
– ".git/"
– ".gitignore"
– ".sass-cache/"
– "bin/"
– "tmp/*"
– "Gemfile*"
– "Movefile"
– "wp-config.php"
– "wp-content/*.sql"
# paths: # you can customize wordpress internal paths
# wp_content: "wp-content"
# uploads: "wp-content/uploads"
# plugins: "wp-content/plugins"
# themes: "wp-content/themes"
# languages: "wp-content/languages"
# themes: "wp-content/themes"
# ssh:
# host: "host"
# user: "user"
# password: "password" # password is optional, will use public keys if available.
# port: 22 # Port is optional
# rsync_options: "–verbose" # Additional rsync options, optional
# gateway: # Gateway is optional
# host: "host"
# user: "user"
# password: "password" # password is optional, will use public keys if available.
# ftp:
# user: "user"
# password: "password"
# host: "host"
# passive: true
# production: # multiple environments can be specified
# […][/code]
“staging:”以下の情報を編集します。
“database:”, 必要に応じて”exclude:”など編集します。
僕の場合は網元なので、ssh:”以下を必要部分だけコメントを外します。
ftpでも行けちゃうのが便利っす。レンタルサーバでもOK 😀
※ Movefileもインデントがキモで、コメントを外して有効化する場合、インデントの位置も必ず合わせる必要があります。
Movefile編集後はこんな感じ。
[code]
local:
vhost: "http://wordpress.local"
wordpress_path: "/var/www/vhosts/private.hibou-web.com"
database:
name: "wordpress"
user: "wordpress"
password: "wordpress"
host: "192.168.66.66"
staging:
vhost: "WordPress アドレス (URL)"
wordpress_path: "/var/www/vhosts/…." # use an absolute path here
database:
name: "DB名"
user: "DBユーザー名"
password: "DBパスワード"
host: "DBホスト"
exclude:
– ".git/"
– ".gitignore"
– ".sass-cache/"
– "bin/"
– "tmp/*"
– "Gemfile*"
– "Movefile"
– "wp-config.php"
– "wp-content/*.sql"
# paths: # you can customize wordpress internal paths
# wp_content: "wp-content"
# uploads: "wp-content/uploads"
# plugins: "wp-content/plugins"
# themes: "wp-content/themes"
# languages: "wp-content/languages"
# themes: "wp-content/themes"
ssh:
host: "ホスト名"
user: "ユーザー名"
# password: "password" # password is optional, will use public keys if available.
port: 22 # Port is optional
rsync_options: "–verbose" # Additional rsync options, optional
# gateway: # Gateway is optional
# host: "host"
# user: "user"
# password: "password" # password is optional, will use public keys if available.
# ftp:
# user: "user"
# password: "password"
# host: "host"
# passive: true
# production: # multiple environments can be specified
# […]
[/code]
環境に合わせて編集したら保存してvagrantにログイン
[code]vagrant ssh[/code]
/vagrant/ディレクトリへ移動して、wordmoveコマンドを実行!!
一先ず、リモートからデータをPULLしてみます。
[code]wordmove pull –all[/code]
WordMoveのコマンドはまるっとだけではなく、データベースのみ、テーマのみなど、お好みで指定した部分のみやり取りすることもできます。
wordmove pullの場合はこんな感じ。
[code][vagrant@wordpress vagrant]$ wordmove help pull
Usage:
wordmove pull
Options:
-w, [–wordpress], [–no-wordpress]
-u, [–uploads], [–no-uploads]
-t, [–themes], [–no-themes]
-p, [–plugins], [–no-plugins]
-l, [–languages], [–no-languages]
-d, [–db], [–no-db]
-v, [–verbose], [–no-verbose]
-s, [–simulate], [–no-simulate]
-e, [–environment=ENVIRONMENT]
-c, [–config=CONFIG]
[–no-adapt], [–no-no-adapt]
[–all], [–no-all]
Pulls WP data from remote host to the local machine[/code]
早速このブログのデータをまるっと持ってきます。
wordmove pull –all 😀
今回は約6分程でローカルに持って来れました。
vccw-team/vccwのreadme.mdに
Contribute
Setting up
- Clone this git repository on your local machine.
- Run
bundle install
to fetch all dependencies.Running and writing tests
There is automated tests using Serverspec.
The tests files are in the
spec/
directory.To run the Serverspec tests, just run
rake spec
.
とありました。これもやってみなければ!!