Different between MyISAM and InnoDB

MyISAM means MYSQL Indexed Sequential Access Method. Basically, It is a flat file, and is very old technology. But do not let that put you off using it. Because a flat file means it is not relational, and thus is not an RDBMS, and thus is more appropriate for some situations.
InnoDB is the full RDBMS like almost one you know.  InnoDB is great for if you have a lot of relational links (with references, joins, etc).

With MyISAM, It implements locking on the table, and while that lock is held, no other session can perform a SELECT. With InnoDB, It implements locking on the row.

Additional thing, MyISAM supports full-text search.

Both MyISAM and InnoDB are good. But when you design database you need determine if you need features provided by InnoDB. If not, then MyISAM is up for consideration.


Send mail in Ubuntu server with Gmail SMTP

In a web project, email function is quite important thing.  For sending email you can use a free SMTP server or sendmail function in your server. So how to send mail in Ubuntu server? The answer is Postfix or SSMTP.  But SSMTP is simper way. Because all we have a free smtp server (e.g Gmail SMTP), and also SSMTP is easier to install.

A wise man never knows all, only fools know everything

A wise man never knows all, only fools know everything

Now, you install SSMTP packet:

And open the config file:

Add new content as below (do not forget change your_emal and your_gmail_password, your_gmail_username):

(It seems that Gmail is more secure, so you have to enable less secure to use SMTP Gmail https://www.google.com/settings/security/lesssecureapps)

To test, you need install send mail client:

Finally, do a test:

You are a PHP developer, the server now can run mail php function. However, you are using Swiftmailer Library, you will got a error message as below:

Because Swiftmailer always try to telnet to localhost to check mail server before sending mail. But SSMTP does not support telnet.

So It is time to use Postfix, I will have a article to so you some tips to install it.

Check port with lsof command

When you need to install a new packet (e.g: Jira, Jenkins, apache2, etc) . You should check ports is available or not. The below I will show you the way to check port with lsof command

In Ubuntu, you and install LSOF with command:


How to manage selinux in CentOS

SElinux means Security-Enhanced Linux is a Linux kenel security module that provides the mechanism for supporting access control security policies. So I will show you some commands to answer the question how to manage selinux.

To show status of Selinux:

To change selinux policies (e.g: httpd_can_network_connect_db parameter) :

That’s all 🙂

Install PHP Web server on Centos

When you have a new VPS installed CentOS to use as web server, you need install some basic packets as apache, mysql, php and setup web server.  You will ask yourself that how to install php web server on CentOS? So I will show you steps to implement it as the below.

Installing httpd:

Make sure that you have root permission

Install mysql server:

Installing PHP:

Now, we will setup web server for new domain that was pointed to the ip address of new VPS.

Create web directory:

Create a test file:

Open httpd.config file:

Add lines below to the bottom of httpd.conf file:

Check iptables firewall to make sure that port 80 is opened:

Or open port 80 if needed:

So now, you can access your website  example.com.



Ubuntu apt-get update does not work

If you are working with a old version of Ubuntu that has reached the end of their support (EOL – end of life). You can be got a error when you use apt-get command like the below:

There are some reasons make apt-get command do not work, e.g: no internet connection, not correct DNS server, …. However, in this article, I just talk about the reason come from the version of Ubuntu that has reached the end of the support. It means the original repositories are closed and no longer able to install software. So you have to set the repository list so that it references to the server – old releases.ubuntu.com (as show below).

Firstly, check your version of Ubuntu:


Now, open the repository list file /etc/apt/source.list and replace all the code by:

Taking care to replace the term CODENAME with the code name for the version of Ubuntu derived in the previous step. (e.g: raring)

After done editing sources.list,  type:

You are done.

PHP create a class with dynamic variables

PHP provides overloading methods to help you create dynamically properties and methods. In this case we will use 2 functions __set() and get(). The below is the concept of  that two functions.

__set() is run when writing data to inaccessible properties.
__get() is utilized for reading data from inaccessible properties.

Now, we will write a class with dynamic variables using __get(), set() functions.

If you do not know about magic functions in PHP, this issue will is not easy for you. But, if you know it, it is so simple.

Difference between Static Method and Dynamic Method

The easiest way to understand is we should start from looking at our code to know how to we used Static Method and Dynamic Method,

With Static Method:

With Dynamic Method:

So you will easily to recognize that Static Methods are usually used in static library. For example, you create a class to handle string as cuting string, uppercase … And based on the script above,  we see that Dynamic Method just is used after creating a instance of object.

You do not need to concern to performance when choose Static or Dynamic Method, just focus to software design. You can use Static Method when you need and choose Dynamic Method when you need instantiate your class.

GIT – Keep files when merge conflict

With Git, sometimes you need merge between branches.  For example, you need merge BranchB to BranchA. Almost cases, if it has conflicts, you will open the conflict file and merge it manually. But in some cases, you have to keep file at either BranchA or BranchB. Fortunatly, “git checkout” command with options will help you do that.

To merge between 2 local branches:

Or merge a remote branch to a local branch:

To keep the file that we own:

To keep the file that they own:

In case you have too many files conflicted, you can use the command below: