[VCCW] WordPress 用の Vagrant 環境 VCCW を利用する

バージョンの切り替えが楽すぎてうれしい。

[markdown]
## VCCW とは

[以前に Vagrant の勉強をかねて環境を作りました](https://www.d-wood.com/blog/2013/09/20_4688.html)が、VCCW はプロが作った WordPress 用の Vagrant 環境。

> * [VCCW – Vagrant based development environment for WordPress](http://vccw.cc/)
> * [WordPress用のVagrant環境VCCWが大幅にパワーアップしました。 | firegoby](http://firegoby.jp/archives/5542)

こちらのスライドが参考になります。

> [入門 Vagrant + WordPress](http://firegoby.jp/presentations/vagrant)

## インストール

VirtualBox と Vagrant はインストール済として。

> [Vagrant: + VirtualBox で仮想マシンを作成する | deadwood](https://www.d-wood.com/blog/2013/09/20_4688.html)

vagrant-hostsupdater plugin をインストールしておく。

“`prettyprinted
% vagrant plugin install vagrant-hostsupdater
“`

> [Vagrant: vagrant-hostsupdater で /etc/hosts を書き換える | deadwood](https://www.d-wood.com/blog/2014/08/25_6669.html)

## つかいかた

サンプルファイルがあるので、[公式の情報](http://vccw.cc/)どおりに立ち上げるだけでOK。

“`prettyprinted
% git clone git@github.com:miya0001/vccw.git
% cd vccw
% cp Vagrantfile.sample Vagrantfile
“`

このようにファイルが配置されています。

“`prettyprinted
.
├── README.md
├── Vagrantfile
├── Vagrantfile.sample
├── cookbooks
│   ├── apache2
│   ├── build-essential
│   ├── iptables
│   ├── mysql
│   ├── openssl
│   ├── php
│   ├── xml
│   └── yum
└── site-cookbooks
├── vccw
└── wp-cli
“`

“`prettyprinted
% vagrant up
“`

www/wordpress が同期されています。

“`prettyprinted
.
├── README.md
├── Vagrantfile
├── Vagrantfile.sample
├── cookbooks
│   ├── apache2
│   ├── build-essential
│   ├── iptables
│   ├── mysql
│   ├── openssl
│   ├── php
│   ├── xml
│   └── yum
├── site-cookbooks
│   ├── vccw
│   └── wp-cli
└── www
└── wordpress
“`

## Vagrantfile

調整しそうな項目はこのあたりでしょうか。
変更したら `vagrant provision`

“`ruby:Vagrantfile
#
# Configuration for the WordPress
#
WP_VERSION = ‘latest’ # latest or 3.4 or later or http(s):// URL to zipfile
WP_LANG = “en_US” # WordPress locale (e.g. ja)
WP_HOSTNAME = “wordpress.local” # e.g example.com
“`

ありがとうございます。ありがとうございます。

## カスタマイズ

というか補足というか。

### 開発時のファイル配置について

ちなみに synced_folder の場所を変更してみようとしたのですが、guest サーバのドキュメントルートなども変わってしまうようなので、さわらない方が良さそうですね。

“`ruby:Vagrantfile
config.vm.synced_folder “www/wordpress/”, “/home/deadwood/www/www/wpmt”, :create => “true”
“`

兄弟プロジェクト?の [iemoto](https://github.com/megumiteam/iemoto) を見ると、`vccw/www/wordpress/wp-content/themes/` 以下(guest OS)に、ディレクトリを切って展開するイメージのよう。
ローカルの Mac で開発し、dist ディレクトリにファイルを作成しているような場合、下記のようにシンボリックリンクを貼ってみたんですがうまく動かなかったので一工夫いりそうです。

“`prettyprinted
% ln -s ./dist vccw/www/wordpress/wp-content/themes/foo
“`

私の場合は、grunt-rsync でディレクトリを同期させてみたところ、うまく認識してくれました。

> * [Grunt: rsync で開発サーバへ deploy する | deadwood](https://www.d-wood.com/blog/2014/08/26_6710.html)

### エラーログ

/var/log/httpd/ 以下に wordpress 関連のログがありました。

“`prettyprinted
[vagrant@wordpress ~]$ ls /var/log/httpd/
error.log wordpress-access.log wordpress-error.log wordpress-rewrite.log
“`

開発中は `vagrant ssh` した後に、こんな感じでしょうか。

“`prettyprinted
[vagrant@wordpress ~]$ tail -f /var/log/httpd/wordpress-error.log
“`

## 補遺

時間があるときにまた確認する。
WordPressテーマ用の grunt-init テンプレート

> * [megumiteam/iemoto](https://github.com/megumiteam/iemoto)

WordPressプラグインの grunt-init テンプレート

> * [megumiteam/hatamoto](https://github.com/megumiteam/hatamoto)
[/markdown]