Install MongoDB and Mongo PHP in Ubuntu

I am using Ubuntu Server 14.04 OS for my working enviroment. All steps below is way I implemented successfully on my machine. So now, I will show you how to install MongoDB and Mongo PHP driver.


Firstly, install MongoDB. You can see it is so simple and one and only one command.

To make sure that MongDB is running, you can use command below

To install Mongo PHP Driver, you use the command below.

The command above use Pecl, so if you machine have not installed it yet. You can install easily by the command below

And now, you have to enable Mongo PHP extension by way add “” to php.ini file or use the commands below

Almost done, just need to check that your job is done or not.

And writing a php script to create document, collection and insert data to mongodb.

If success, the output will be same as the below


Vim install Vumdle

To read this article, you have to make sure that you know linux command and your machine was installed VIM, GIT.

Firstly, install vumdle plugin by command:

And then,you go to your home directory and look for .vimrc. Open it and add lines below

So now, you can open vim and type:

And waiting for all plugin that you put to .vimrc file is installed completely.


Set Static IP in Ubuntu Server

To set static IP for Ubuntu Server, we just need to modify file /etc/network/interfaces. The example below shows that we set static IP for ethernet interface eth0 to

And on/off interface:


Convert GIF to MP4 in Ubuntu

To convert GIF file to MP4, we need implement two steps. The first step is convert git frames to png files. With this step, you need use ImageMagick. So you need make sure that your machine was installed ImaegMagick. The second step is convert the PNG file to MP4. We use AVCONV(ffmpeg) for this step. For further details, please take look to the steps below.

Convert GIF to MP4 in Ubuntu

Install ImageMagick (In Ubuntu)

Install AVCONV (ffmpeg)

Convert GIF frames to PNG images

Compress multi png images to video MP4


Install PHP Redis in Ubuntu

Redis is good solution to improve the performance of your system. You can use Redis as cache system or nosql DB.  I think that is is easy to use it but not easy to think how and where.

Step 1,  install redis, phpize

Test redis:

Install phpize

Step 2,  download phpredis source code from git

If you have not installed git yet, you can use this command line:

Step 3, compile and install phpredis,

Step 3, enable phpredis extension

Step 4, test

Writing a php script to test

Doing some quick and dirty benchmark


Good luck,

AngularJS, Set Image always in the center of DIV

Will have a time you need set email always in the center of DIV tag, even it is horizontal or vertical image. So now, I shared a angularjs directive that will do it for you. In this code, It will cacth event image loaded and check image is horizontal or vertical and set a suitable margin and position.


AngularJS and Scroll lazy load directive

Lazy load is a familiar task when you work with web application. For example,  when you scroll your application to the bottom of page, you want to load more data from server side. This will make a better user experience and app performance.

In angularJS, you should create a directive that will catch scroll event and call load more data function in controller when user scroll to bottom of page.

loadMoreData() function is wrote in Controller that will handle task load more data from server and bind to $scope