Set up Zend Framework Skeleton Application on Mac Step by Step

1.Install Composer

Follow Composer official guide and install it locally:

Run the following commands:

$ php -r “copy(‘’, ‘composer-setup.php’);”

$ php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘070854512ef404f16bac87071a6db9fd9721da1684cd4589b1196c3faf71b9a2682e2311b36a5079825e155ac7ce150d’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”

$ php composer-setup.php

$ php -r “unlink(‘composer-setup.php’);”

Here is the screenshot of what I did:


I got a warning about OpenSSL version, we can just ignore it for now.

Now I can see that composer.phar has been created in my file system:




2.Verify that Composer is installed successfully:

Since I installed Composer locally, so when I need to run Composer, I need to cd into the installation path, and run

$ php composer.phar



If you want to install Composer globally, you can follow this guide:



3. Install ZendSkeletonApplication

Follow the instruction on the Github repository:

Here I want to clone the application in “zend” folder, so I run this command:

$ php composer.phar create-project -n -sdev zendframework/skeleton-application zend

The screenshot:





4. Verify that ZendSkeletonApplication has been installed successfully

We can see that a “zend” folder is created and the application files are placed inside:


Start apache server(my apache root directory is parent folder of “mysites”), go to http://localhost/mysites/zend/public/

We can see the skeleton application running:






Host a website on Amazon AWS step by step guide

1.Sign in to the console using AWS credentials.

You will see a page listing all AWS web services:




2.Click on “EC2” to go to EC2 dashboard:QQ20160515-1



3.Click on “Launch Instance” to start the process of  creating a new EC2 instance:


Notice: there should be a step to create security key pairs for later access to running EC2 instance. But since I’ve already created one in my account, the system skips the step. Just remember to save the private key to a safe place, we will need it to SSH into the instance later.


3.1Choose AMI

Here I will just choose the forth one: Ubuntu Server.



3.2Choose Instance Type

Here just choose the default one:



3.3Configure Instance Details

Here we can keep everything default, no need to change any settings:




3.4Add Storage

Here we can keep everything default, no need to change any settings:




3.5Tag Instance

Here the Value we put will be the name of this instance, and it will be displayed on our AWS EC2 dashboard:




3.6Configure Security Group

This step is very important!

Firstly, I want to talk about my failure experience:

According to my experience, normally if I start something new, default is most likely to be a good choice.

So for “Assign a security group”, I selected the “Select an existing security group” radio button, and chose the first security group listed, whose name is “default”. The following is the screenshot:


And I just clicked the “Review and Launch” button.

Then I waited for a few minutes for the instance to be running. Sadly, because of the default group setting, I couldn’t SSH into the instance, which means I could do nothing about the instance. The instance was dead for me!


After checking some tutorials, I got to know that I have to create a new security group and add custom access rules. Here is the screenshot of the rules we need:


4.Then we can see the running instance in EC2 dashboard




5.SSH into the instance

In command shell, cd to the directory that the private key is located. Then run this command:

$ ssh -i [private_key_file_name] ubuntu@[public_DNS_address]

For example:



6.Run as root and access website folder

$ sudo su

$ cd /var/www/html/











Consul & Registrator & Rails Service all together in separate Docker container

1.Start a container running Consul:

Here we use this image:

$ docker run -it -h node -p 8500:8500 -p 53:53/udp progrium/consul -server -bootstrap -advertise  $DOCKER_IP


How to check that Consul is running:


In Docker-Machine, run

$ docker ps

Will see running Consul container:


We can also check the logs:

$ docker logs $CONTAINER_ID



Browse to $DOCKER_IP:8500 there is a dashboard to see the services that are registered in Consul:




2.Start a container running Registrator

Here we use this image:

Registrator automatically registers and deregisters services for any Docker container by inspecting containers as they come online.

Registrator watches for new Docker containers and inspects them to determine what services they provide. For our purposes, a service is anything listening on a port. Any services Registrator finds on a container, they will be added to a service registry, such as Consul or etcd.

$ docker run -it -v /var/run/docker.sock:/tmp/docker.sock -h $DOCKER_IP gliderlabs/registrator consul://$DOCKER_IP:8500


How to check that Registrator is running?

In Docker-Machine, run

$ docker ps

Will see running Registrator container:


We can also check the logs:

$ docker logs $CONTAINER_ID




3. Start a web service and let Registrator automatically register it on Consul

In command line, into a directory that has proper rails app, Dockerfile and docker-compose.yml file in place.

$ docker-compose build
$ docker-compose run web bundle exec rake sample_data:populate
$ docker-compose run -p 3000 -e ‘SERVICE_NAME=romui-web’ web rails s

How to check that this service is registered?


Use Consul API:

$ curl $DOCKER_IP/v1/catalog/services


We can check the service details using Consul HTTP API:

$ curl http://localhost:8500/v1/catalog/service/$SERVICE_NAME



Check in Consul UI:



4. Find the IP address and port of the service from Consul UI, and start using the service.


Now we are ready to access the service from browser:



[Consul]Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.

Problem: Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.

I’m new to Consul, so on my windows system, I was following the official guide:

until this step:

$ consul agent -dev

and get this error:



Why got this error:

If we don’t specify a bind address, Consul will by default listen on the first private IP on the system, and this might not work.

An explanation of private IP address vs public IP address



To solve the problem, we need to explicitly specify it.

Step1: Find the private IPV4 address of this system:

$ ipconfig


We can see from the screenshot, the IPv4 Address is

Step2: Specify the bind address  and start the agent:

$ consul agent -dev -bind


From the above screenshot, we can see now the agent is successfully up and running.

Docker/Gitlab CI – Environment Set Up Guide

1. Install Docker Engine

Use Ubuntu as example, follow the official installation guide before the “Optional Configurations” section:

In “Optional Configurations” section, only need to do “Create a docker group” and “Configure a DNS server for use by Docker”.

Create a docker group:

Why: Need to do this so that we can run docker without sudo.

Test that it works:

$docker ps

Configure a DNS server for use by Docker:

Why: Need to do this so that docker engine can resolve hostnames.

Test that it works:

$docker run -it ubuntu /bin/bash


An example error screenshot of not having this configured:

2. Install Docker Compose

Follow official guide:
3. Install GitLab CI Runner and register multiple runners to use with Docker

Follow this guide:
4. Set up job to clean non-tagged images and stopped containers

Use meltwater/docker-cleanup:

USB storage capacity reduced to 2MB from 14GB


I created a bootable USB stick on Windows. Then My USB storage capacity reduced to 2MB from 14GB.





Follow the steps from this link:

The following is the screenshot of what I did:



Now we can see that Used space and Free space both become 0 bytes:



We need to format the disk:



After formatting, we could see that the USB’s capacity turns back to be normal:


Install and set up multiple Gitlab CI Runners to use Docker

GitLab CI allows you to use Docker Engine to build and test docker-based projects.

We will follow the official guide: Using Docker Build

Here we choose the first method “Use shell executor”.

1.Install GitLab Runner:

Here we install gitlab-ci-multi-runner on linux. Follow this official guide until “Register the runner”: Install using official GitLab repositories

2. Register the runner:

Using Docker Build is trying to register the runner in non-interactive way. Somehow it doesn’t work. Here we follow the registration step in Install using official GitLab repositories, installing in interactive way.


As we can see from the above picture, we will need to provide coordinator URL and token. They can be found in your repository at “Settings” -> “Runners”:


And one thing different from the screenshot, For “Pleasse enter the executor: shell, docker, docker-ssh, ssh?” We need to type in shell.


After registering, we should be able to see the runner in “Settings” -> “Runners”:


3. Install docker, set up privileges.

Just continue following Using Docker Build  “Use shell executor” section.

4. Register multiple runners and make them run builds concurrently.

The runner config file is located at:



The concurrent is default to 1. Here we use 3 concurrent runners, so we set it to 3.

5. Verify whether runners are running or not:

$sudo gitlab-ci-multi-runner verify