Use VCCW For Deploying WP

For deploying differenet versions of Wordpress, I searched various kinds of solutions, includeing docker and vagrant, finally I found VCCW(A Wordpress development environment) is what I want, because I could freely changes the WP versions, so following is the guideline for installing and configurating the whole virtualmachine.

Install

The installation steps are listed as:

$ vagrant plugin install vagrant-hostsupdater
$ wget https://github.com/miya0001/vccw/archive/1.9.1.tar.gz
$ tar xzvf 1.9.1.tar.gz
$ cd vccw-1.9.1
$ vagrant up

This will start downloading and configrating the VM, it will cost sometimes. So just drink a coffee and get back.

$ vagrant plugin install vagrant-omnibus && vagrant plugin install vagrant-hostsupdater &&  vagrant plugin install vagrant-proxyconf

Configure proxy and chef?

$ vim Vagrantfile
Vagrant.configure(2) do |config|
  config.proxy.http     = "http://1xx.xx.xx:xxx:2xxx"
  config.proxy.https    = "http://1xx.xx.xx:xxx:2xxx"
  config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"

config.omnibus.chef_version = :latest
$ VAGRANT_APT_HTTP_PROXY="http://1xx.xx.xx.xxx:2xxxx vagrant up
$ VAGRANT_APT_HTTP_PROXY="http://1xx.xx.xx.xxx:2xxxx vagrant provision

vagrant halt

Flask&AngularJS Blog Tips

Background

For setup the local blog which used for recording some articles, and provide the RESTful APIs for remote usage.
The tutorial is located at:
http://blog.john.mayonvolcanosoftware.com/building-a-blog-using-flask-and-angularjs-part-1/

Installation of Packages

First preapare the environment using virtualenv2:

$ virtualenv2 flask_blog
$ source flask_blog/bin/activate

Now write a requirements.txt file, under the current folder, the content is:

Flask==0.10.1
Flask-Bcrypt==0.6.0
Flask-HTTPAuth==2.2.1
Flask-RESTful==0.2.12
Flask-SQLAlchemy==1.0
Flask-WTF==0.10.0
Jinja2==2.7.3
MarkupSafe==0.23
SQLAlchemy==0.9.7
SQLAlchemy-Utils==0.26.9
WTForms==2.0.1
WTForms-Alchemy==0.12.8
WTForms-Components==0.9.5
Werkzeug==0.9.6
aniso8601==0.83
decorator==3.4.0
infinity==1.3
intervals==0.3.1
itsdangerous==0.24
marshmallow==0.7.0
py-bcrypt==0.4
pytz==2014.4
six==1.7.3
validators==0.6.0
wsgiref==0.1.2

Use pip install -r requirements.txt for installing all of the packages.

Trouble Shooting On Wicd Wireless Connection

Problem

Could see the SSID, but could not connect to it.

Trouble Shooting

First check the log in /var/log/wicd:

[root@TrustyArch wicd]# cat wicd.log
2014/12/04 20:32:02 :: DHCP connection successful
2014/12/04 20:32:02 :: not verifying
2014/12/04 20:32:02 :: Connecting thread exiting.
2014/12/04 20:32:03 :: Sending connection attempt result success
2014/12/04 20:34:20 :: trying to load backend external
2014/12/04 20:34:20 :: trying to load backend ioctl
2014/12/04 20:34:20 :: WARNING: python-iwscan not found, falling back to using iwlist scan.
2014/12/04 20:34:20 :: WARNING: python-wpactrl not found, falling back to using wpa_cli.

I think it’s because the dhcpcd still alive, so manually kill this process via pkill dhcpcd, then re-connect again.
Trouble Solved.

Enable Timestamp In New Octopress Theme

After installing the flattern theme of octopress, I found the post date missed. Following is the steps for catching it back.

rake install['flatten']

Modify the following file:

$ cat .themes/flatten/source/_includes/post/date.html

Then in .themes/flatten/source/_layouts/post.html, modify the following lines:

    <p class="meta">
    //.....//
    </p>

After modification, you would see the time is displayed before the comment numbers.
Notice, the modification is not visible in codeblocks because the embedded symbol could not be resolved thus will cause build error, so the detailed code would be only fetched from my github repository but remains blank codeblocks here in this article.

Use Docker for deploying WP

Just for swiftly deploy WP and test the RESTful API, I did following operations and runs a WP temporately.

PULL

Pull following containers:

$ docker pull mysql
$ docker pull wordpress
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>              <none>              480ac552cd39        About an hour ago   192.8 MB
mysql               latest              98840bbb442c        39 hours ago        235.5 MB
wordpress           latest              9f51af77fd96        8 days ago          470.5 MB

Configuration

Explanation for following commands, --name is the name for our container, -p 8038:80 is mapping the host machine’s 8038 port to container wordpress_1:

$ docker run --name mysql_1 -e MYSQL_ROOT_PASSWORD=xxxx -d mysql
$ docker run --name wordpress_1 --link mysql_1:mysql -p 8038:80 -d wordpress

Now open your browser to http://localhost:8038 and you got the wordpress installation window.

WP

After we installed WP, we could install JSON REST API from:
https://wordpress.org/plugins/json-rest-api/
After installation, we could test the REST API via curl:

TBD

View Docker status

First we should grab the docker’s PID via following command:

$ docker  inspect  --format "{{ .State.Pid }}"  mysql_1 
28254
$ docker  inspect  --format "{{ .State.Pid }}"  wordpress_1
28754

Then we could nsenter the docker container and view its status:

$ sudo nsenter --target 28254 --mount --uts --ipc --net --pid -- /bin/bash
$ sudo nsenter --target 28754 --mount --uts --ipc --net --pid -- /bin/bash

In the ‘attached’ environment we could inspect the status for corresponding services.

Stop docker contains

via docker stop we could simply stop the docker container:

[Trusty@~/code/30days/Docker]$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                  NAMES
0995854e2144        wordpress:latest    "/entrypoint.sh apac   About an hour ago   Up About an hour    0.0.0.0:8038->80/tcp   wordpress_1         
99d257ad6e24        mysql:latest        "/entrypoint.sh mysq   About an hour ago   Up About an hour    3306/tcp               mysql_1             
[Trusty@~/code/30days/Docker]$ docker stop 0995854e2144
0995854e2144
[Trusty@~/code/30days/Docker]$ docker stop 99d257ad6e24
99d257ad6e24
[Trusty@~/code/30days/Docker]$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES