Category Archives: PHP

Build Redis and PHPRedis from source codes

Install Redis

For more info please check

Copy the Redis server and the command line interface to “/usr/local/bin/”

Continue reading

Installing Nginx, php-fpm and Mongodb on Ubuntu

Installing Nginx

Add nginx signing key to sign the nginx packages and repository to the apt program keyring. Moe detail:

or try:

Add the following to  the end of  apt config file:  “/etc/apt/sources.list”. “trusty” is the codename of nginx for ubuntu 14.04, for the other version of ubuntu please  check:


Installing php5

Continue reading

Phalcon Configure custom routes

By default, Phalcon will not use routing system to map http request uri to controller and action. This is different from other frameworks like zf2, laravel … But it is not a hard work to configure your custom routes.

Inject router into Phalcon Application by adding the following code to “app/config/services.php

Create new php file “app/config/routes.php

By default the URI information is obtained from the $_GET[‘_url’] variable, this is passed by the Rewrite-Engine to Phalcon, you can also use $_SERVER[‘REQUEST_URI’]

If you set the namespace for the controller in the file “app/config/loarder.php”

The router also need to set default namespace

$router->notFound just as it said by itself. For the not found page we also need add the http status code 404 in the action:


For more info about Phalcon routing please check:

The First Phalcon App

Install Phalcon on Linux

Create the extension

Add the extension to php.ini

Restart php-fpm

Install Phalcon Developer tools

create composer.json

edit composer.json

install via composer

Create a project skeleton

Edit Nginx config

Then Configure the custom routing

Laravel Without Blade

I has been using Laravel for a while, I like but I cannot stand to use blade as template. To disable it is very easy, just see the following example

1. Add the code ” protected $layout = ‘layout.main’ to the file BaseController.php

2. Create layout “layout/main.php

3. Edit file “HomeController.php”

4. Create template “home/welcome.php


Building MongoDB PHP driver by phpize

Download the source code from Github. The run the following commands:

For more detail how to build php extension please check this example: Building MySQL Native Driver(Mysqlnd) for PHP by phpize

Install WordPress with Nginx on Ubuntu

This documents covers how to install WordPress with Nginx on Ubuntu.

WordPress is an open source web software used to create website based on PHP and MySQL. WordPress is used by more than 22.0% of the top 10 million websites as of August 2013, according to Usage of content management systems for websites.

nginx (engine x) is an open source reverse proxy server for HTTP mail, written by Igor Sysoev. It was used by 21.5% of the top 1 million websites, 29% of the top 100,000 websites, and by 38.5% of the top 1,000 websites according to Usage of web servers broken down by ranking. Continue reading

Building MySQL Native Driver(Mysqlnd) for PHP by phpize

After building PHP with PHP-FPM for Nginx server and building MySQL server. This document shows you how to build Mysqlnd(MySQL Native Driver) .

Mysqlnd is written in C as a PHP extension, so it is unlike the older MySQL client library that was written by MySQL AB(Oracle Corporation) under MySQL license, it is released under the PHP license.

Using Mysqlnd you don’t need to copy the MySQL client library, so this much more convenient for web server without MySQL server.

Using MySQL Native Driver leads to better performance than using MySQL Client, especially when it comes to memory usage, as a PHP extension, the driver uses the PHP memory management, so it is supports the PHP memory limit. Using the MySQL Client Library, each row is stored in memory twice, whereas with the Mysqlnd each row is only stored once in memory. Continue reading