One story that VCCW can make building local environment and deploy on production of Wordpress much easier

As I described here, I got technical trouble and I couldn't resolve it soon when I build local environment of Wordpress.
Then I decided to change the way of it and I chose VCCW.

VCCW is very great tool to realize very very easily building local environment and deploy on production of Wordpress developed by Japanese engineers as OSS.

In this blog I'd like to introduce it.

What we can do

With using VCCW I just build local environment and synchronize between local and production environment. But I see it has the other lots of functions such as PHPUnit, CodeSniffer, Node.jsGrunt and so on. I've not tried them yet but.


The way to install is very very easy and basically only following homepage.
Firstly please install Vagrant and VirtualBox by yourself on your local PC.

Install vagrant-hostsupdater plugin

$ vagrant plugin install vagrant-hostsupdater

Git clone VCCW on a directory of your local



Modify site.yml

In order to synchronize code on host machine and guest machine via Chef, you need to modify site.yml.
$cp ./provision/default.yml ./site.yml
$vi ./site.yml
I recommend you modify these configs.
# Virtual Machine Settings
memory: 1024 
# Network Settings
hostname: HOST_NAME
# WordPress User
# phpenv
php_version: 5.6.9
You need to confirm what version you can specify here.

Try to boot local environment

$ vagrant up
Then you can access to it with domain specified in hostname above on browser like this.

Modify Movefile

After vagrant up, you can find Movefile. This is configuration file for wordmove command, which enable us to deploy code on GUEST machine to production environment (actually not only production but we can specify any environments).
I recommend you modify these configs.
  vhost: "http://PUBLIC_DOMAIN"
  wordpress_path: "PATH_TO_FOLDER_OF_CODE" # use an absolute path here 
    name: "DATABASE_NAME"
    user: "USER_NAME"
    password: "PASSWORD" 
    host: "PUBLIC_DOMAIN"
    port: 22 # Port is optional

Try to log into staging environment

Staging environment means an environment that you want to deploy source code you specified above. It's just a name and of course you can use it as production too.
In order to deploy source code to it, wordmove command is helpful. But before you try this command, you'd better log in to staging environment by ssh command from GUEST machine in advance because wordmove command must be executed in GUEST machine.
$ vagrant ssh
If you can log in to it successfully, you can try wordmove command. But I guess you must be unsuccessful if you adopt key authentication like Amazon EC2.
I'll post another blog how to resolve it.

Deploy source code

As I described above, it's very easy to deploy and synchronize database (not only them but also plugins!) with using wordmove command.

Example (synchronize everything from guest machine to staging)

$ vagrant ssh
$ cd /vagrant
$ wordmove push --all

Example (synchronize everything from staging to guest machine)

$ vagrant ssh
$ cd /vagrant
$ wordmove pull --all

These examples have 2 important points.

  • We must run this command on guest machine.
  • wordmove command enables us to synchronize in both ways.
Also, wordmove command has lots of options and you can specify what you want to synchronize.

:wordpress | -w
Synchronize souce code without the ones excluded by Movefile.
:uploads | -u
Synchronize uploads folder.
:theme | -t
Synchronize wp-content/theme folder.
:plugins | -p
Synchronize wp-content/plugins folder.
:language | -l
Synchronize only *.mo and *.po onp-content/languages.
:db | -d
Dump of DB by mysqlsump then restore by mysql command.
:verbose | -v
Show detail of message.
:simulate | -s
So to speak dry run mode. For connection check of remote server and so on.
:environment | -e
Specify an environment to synchronize. This must be defined by Movefile in advance.
:config | -c
Synchronize wp-congig.php too (basically this file is excluded to synchronize).

One more thing

As I described above, VCCW enables CodeSniffer. This command below can realize it on guest machine (very easy!!!).
$ vagrant ssh
$ cd /vagrant
$ wpcs wp-content/plugins/hoge/hoge.php
Or like this to specify multiple files.
$ wpcs wp-content/*
Then you can get the result like this.
   1 | ERROR | [x] End of line character is invalid; expected "\n" but
     |       |     found "\r\n"
     |       |     (Generic.Files.LineEndings.InvalidEOLChar) 


 *** | ERROR | [x] File must end with a newline character
     |       |     (Generic.Files.EndFileNewline.NotFound)
Time: 125ms; Memory: 3.75Mb

References (all in Japanese)

When I find, install and set configs, these articles were very helpful for me.

Official site

Installation and settings

Edit Movefile

Command options of wordmove
If you liked this article

Let's subscribe the updates of Scuti!
Share on Google Plus

About Tomohide Kakeya

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment


Post a Comment