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.js, Grunt and so on. I've not tried them yet but.Installation
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
$ git clone git@github.com:miya0001/vccw.git YOUR_PROJECT_NAME $ cd YOUR_PROJECT_NAME
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.ymlI recommend you modify these configs.
# # Virtual Machine Settings # memory: 1024
# # Network Settings # hostname: HOST_NAME ip: 192.168.66.66 sync_folder: 'PATH_TO_DEPLOY_CODE_ON_HOST_MACHINE'
# # WordPress User # admin_email: YOUR_EMAIL_ADDRESS
# # phpenv # php_version: 5.6.9
You need to confirm what version you can specify here.
Try to boot local environment
$ vagrant upThen you can access to it with domain specified in hostname above on browser like this.
http://HOST_NAME
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.
local: vhost: "LOCAL_HOST_NAME_YOU_SPECIFIED_ABOVE"
staging: vhost: "http://PUBLIC_DOMAIN" wordpress_path: "PATH_TO_FOLDER_OF_CODE" # use an absolute path here
database: name: "DATABASE_NAME" user: "USER_NAME" password: "PASSWORD"
ssh: host: "PUBLIC_DOMAIN" user: "USER_NAME_OF_STAGING_SERVER" 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 $ cd ssh USER_NAME_OF_STAGING_SERVER@ PUBLIC_DOMAINIf 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.phpOr like this to specify multiple files.
$ wpcs wp-content/*Then you can get the result like this.
---------------------------------------------------------------------- FOUND *** ERRORS AFFECTING 206 LINES ---------------------------------------------------------------------- 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) ---------------------------------------------------------------------- PHPCBF CAN FIX THE *** MARKED SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- 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
http://vccw.cc/Installation and settings
http://www.d-wood.com/blog/2014/08/27_6674.htmlhttp://whiskers.nukos.kitchen/2014/09/01/vccw.html
https://firegoby.jp/archives/5921
http://private.hibou-web.com/archives/5415
0 Comments:
Post a Comment