Find out uptime of VPS

My friend send email asking for command line. His boss don’t believe on uptime report  he made. He told me that he got the report from 3rd party that manage the server.  He want to know it and will show the result to his boss.

As far as I know the command for checking are :

1. uptime

# uptime
04:17:02 up 82 days, 23:34,  1 user,  load average: 0.00, 0.00, 0.00

2. w

# w

04:17:05 up 82 days, 23:34,  1 user,  load average: 0,00, 0,00, 0,00
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
root     pts/0    04:16    0.00s  0.03s  0.02s w

As usual for more detail or option available using man.

# man uptime

UPTIME(1)                     Linux User’s Manual                    UPTIME(1)

uptime – Tell how long the system has been running.

uptime [-V]

uptime  gives  a one line display of the following information.  The current time, how long the system has been running, how many users are cur-
rently logged on, and the system load averages for the past 1, 5, and 15 minutes.

This is the same information contained in the header line displayed by w(1).

/var/run/utmp  information about who is currently logged on
/proc     process information

uptime was written by Larry Greenfield <[email protected]> and Michael K. Johnson <[email protected]>.

Please send bug reports to <[email protected]>

ps(1), top(1), utmp(5), w(1)

Cohesive Systems                  26 Jan 1993                        UPTIME(1)

If you want to print it you might want to export it first.

# man uptime > uptime.txt

If you have vps or dedicated server then you can compare it versus confirmation email from provider.

How to Install DragonFlyBSD in VPS using custom iso feature

Distrowatch told me about newest version of DragonFlyBSD (3.8.0) . This version also in my waiting list as I know this BSD variant since beginning. When DragonFlyBSD begin using ports  aka dports to their software installation management then I’m happily use this version as server.

For documentation process when I delegate installation process for my staff I create this simple guide.

Of course its VPS based as we try to minimize physical server for our company 🙂

Create temporary iso location

DragonFlyBSD provide .iso.bz2 link and I have to convert it to .iso first. The idea is create temporary location for iso file and use it for Vultr custom iso.

I think my lowendspririt vps is good place to hold temporary image.

$ ssh [email protected] -p 17020
[email protected]’s password:
Welcome to Ubuntu 12.04 LTS (GNU/Linux 2.6.32-042stab084.17 i686)

* Documentation:
Last login: Mon Jun  9 13:23:09 2014 from
# cd /var/www/
# wget -c
–2014-06-10 10:17:20–
Resolving (… 2001:470:1:43b:1::72,
Connecting to (|2001:470:1:43b:1::72|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 208704827 (199M) [application/x-bzip2]
Saving to: `dfly-x86_64-3.8.0_REL.iso.bz2′


Moving users folder and create symlink

Today I got “error, can not write” message on the bottom of my blog. I think its temporary since I often see the message before (with bluehost).

This afternoon I got another message that confirm me if the message is not usual one. The message is sign of storage full. Yes, the blog move to vps and after checking the status :

# df -H
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       8.4G  7.9G     0 100% /
none            4.1k     0  4.1k   0% /sys/fs/cgroup
udev            511M  4.1k  511M   1% /dev
tmpfs           105M  410k  104M   1% /run
none            5.3M     0  5.3M   0% /run/lock
none            522M     0  522M   0% /run/shm
none            105M     0  105M   0% /run/user
/dev/vdb1        22G   47M   20G   1% /data
# cd /

My VPS utilize 100% of / partition (I thought soft limit is there) and lead me to error message.

I forgot if this VPS use two drive : /dev/vda1 for operating system and /dev/vdb1 for data storage.

To fix the problem I just need to move content from /dev/vda1 to /dev/vdb1

# mv /srv/users/ /data/
# ln -s /data/users /srv/
# ls -l /srv/

total 0
lrwxrwxrwx 1 root root 11 Jun 15 14:56 users -> /data/users

Checking current status now :

# df -H

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1       8.4G  3.6G  4.4G  46% /
none            4.1k     0  4.1k   0% /sys/fs/cgroup
udev            511M  4.1k  511M   1% /dev
tmpfs           105M  410k  104M   1% /run
none            5.3M     0  5.3M   0% /run/lock
none            522M     0  522M   0% /run/shm
none            105M     0  105M   0% /run/user
/dev/vdb1        22G  4.7G   16G  24% /data

The service working well now 🙂

WordPress Featured Image

“I already upload photo for my post but I see blank display on our website”. That question came from my friend who work as webmaster. He is responsible for updating the news on the office website. I promise to take a look and tell you the answer. Actually I was buying time to figure out what caused the problem.

The site has been running for more than 2 years and no significant problems during this period. That changed only version of wordpress.  I think the reason why the picture features running on the website of my friend’s office was not functioning properly is wordpress.

After look around finally I can reproduce the problem and came back with answer 🙂

How to get wordpress featured image work

Simple, create new post, add post title then fill the content. For featured image you must choose it manually from editor menu.


This method also work on image slider aka carousel (many theme use it).

I can’t see Featured Image section

Click “Screen Options” to enable it.

How to install OpenBSD in VPS using custom iso

My friend came up with question about OpenBSD. He ask me about possibility of install OpenBSD remotely and continue to manage it for different purpose. I promise to help but due to time constraint I can not visit his house and teach him. I decide to make this post for him but I hope this simple guide will also help others that might face similar problem.

I use vps service from Vultr for this guide since I can use my existing credit and also quick setup process.

Others series that related to custom iso vps :

Upload OpenBSD iso to VPS server

I use Australia for VPS server location so I use nearest OpenBSD mirror close to Australia (Internode amd64 OpenBSD 5.5). This tutorial use OpenBSD 5.5 but you can change the iso file (I’ll update latest iso list when OpenBSD release new version).

Update on May 12 2015:

OpenBSD 5.7 has released. You can use these iso :

  • 64 bit OpenBSD 5.7 iso, (
  • 32 bit OpenBSD 5.7 iso, (

If you want to use 5.6 release then you can use this iso :

Enter the link on “remote URL” section.

How to install OpenBSD in VPS using custom iso - choose your openbsd iso location file


How to install NetBSD on Vultr using custom iso

Today I want to try custom iso feature that Vultr provide. This time I’ll use NetBSD since the size is small and meet Vultr standard (in their range upload size, at the moment its 5192MB max size ).

Preparation ISO file

At this time NetBSD already reach version 6.1 and I choose to download from master.

  • For NetBSD 6.1.5 iso (x86) click here.
  • For NetBSD 6.1.5 amd64 iso , click here.

For NetBSD legacy version:

  • For NetBSD 5.2.3 iso (amd64), click here.
  • For NetBSD 5.1.5 iso (x86), click here.

Click “My ISOs” link.

upload netbsd iso to vultr

Enter the address of iso file (I use NetBSD-6.1.4-amd64.iso) and click Upload button. More

Optimization Tips for Fresh Store Builder Owner

Last post about how to install Fresh Store Builder (FSB) under VPS using ServerPilot on Vultr lead me to a few things. One of them is optimization. Many FSB owner are non coder and non server folks.

A few things that they can do to optimize the store are :

1. Choosing closest server

If you targeting Amazon UK user then you might want to serve your UK customer using server that located in UK.

If you use Vultr server then you can use UK location.


If you use Digital Ocean then you can choose Amsterdam location.


2. Tweaking Server Setting

By default vps server configured by ServerPilot is more than enough for common task but they do provide a few ‘setting’ left for end user (vps owner).

You can check those aspects using gtmetrix page. For example hosting formula store I create yesterday. Gtmetrix score is here :


A few notes from Yslow grade :


Click the recommendation for “add expire headers” and I see :

That resource is not located in my server and that’s why I can not set the expire from server.

Fortunately all other setting already defined by FSB in .htaccess file.

So far the result is good according to Pagespeed 🙂

Allow remote access to MySQL server from VPS

Today I have job for backup mysql to other server that specialize on mysql backup online. The job is easy but I think it worth to share for someone out there who want to do same thing 🙂

I’ll use my vps on DigitalOcean and MySQL backup service from mysqlbackuponline.


On DO side the steps are :

1. Create database

2. Grant “select” access to the database you want to backup (don’t forget to flush privileges). ex :

grant select on dbname.* to [email protected]’126.220.63.%’ identified by ‘password’;

3. Open firewall access to mysql port, like this :

iptables -A INPUT -i eth0 -p tcp –destination-port 3306 -j ACCEPT

Check if the rule is exist :

# iptables -L -n

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  —             tcp dpt:3306

4. Edit /etc/mysql/my.cnf or /etc/my.cnf (position depend on your server operating system)

Make sure “bind-address” section is right. For me comment the line is enough.

5. Restart MySQL server


On Mysqlbackuponline side the steps are :

1. Login to mysqlbackuponline

2. Click on + Add New MySQL server

3. Enter all requested information

4. Test Connection

Make sure connection work well “Test connection succeeded”.


Test run the job :

11:27:43 AM
Started by a user
11:27:43 AM
Environment version
11:27:45 AM
Starting MySql backup…
11:27:45 AM
Using mode (MySQLTcpIpServer)
11:27:45 AM
Creating a backup of the database: backupdb
11:27:47 AM
Server version : 5.0.95
11:30:55 AM
Archived in 0.02 sec
11:30:55 AM
Archive size 66794 bytes
11:30:55 AM
The backup was saved successfully
11:30:55 AM
Backup state was saved (0.02 sec)
11:30:55 AM
Sending email…
11:30:56 AM
Email have been sent to [email protected]
11:30:56 AM
Job finished (Success)

Great service from mysqlbackuponline. Time to schedule it for daily backup.

Find out specific file (sql file) in vps

2014 is here and happy new year everyone 🙂 . As new year come I want to do ‘clean up’ for some vps and get rid from unused or old file that no longer useful on my vps server. Since the content handle by many side I can not delete many file and only able to delete sql file. The problem is I can not remember where I put the file?

Linux come with ‘find’ command and I can concentrate on “public_html” folder :

$ find public_html -name \*.sql -print

Wow, at least I know that garbage is exist.

Time to work now.

P.S : other useful command


ncdu 1.7 ~ Use the arrow keys to navigate, press ? for help
— /home/working/public_html ——————————————————
5.4GiB [##########]  public_html2014.tar.gz
2.9GiB [#####     ] /picture
2.2GiB [####      ]/cover                                                                                                                    292.9MiB [          ] /Hanz
246.3MiB [          ] /hanz2

ncdu : NCurses Disk Usage


Migrating PHP 5.2.x application from Shared Hosting to VPS

Sorry for not post here for long time 🙂 . Getting busy with teaching and consulting make me forgot about this blog. Today I want to share about my experience dealing with php application that run well on 5.2 version. Client need to migrate it to dedicated server but I suggest to check it on vps first before deploy to dedicated server.

The aim of this job is to create a checklist around installation process, modules and others.

For OS I prefer to use Ubuntu server and I used to get it work for Ubuntu LTS (8.04, 10.04 and 12.04). Simply downgrade current PHP version to use Hardy Heron or 9.10 can save my day but now all those option no longer available since Ubuntu close it.

Further search lead me to Debian. Yes, Debian still give me access to Debian 5 repository where PHP 5.2 exist.

A few important things do before  create the server :

1. Choose cheap but good vps provider. I choose Digital Ocean with their $5/month package.

2, Pick Debian 6, 32 bit . (lighter than 64 bit).

3. Change source.list for these lines :

deb squeeze main
deb squeeze/updates main
deb lenny main contrib non-free

4. Set priority of PHP only use Leny.


Package: *
Pin: release n=lenny*
Pin-Priority: 100
Package: libapache2-mod-php5 php5-dev php5-common php5-curl php5-gd php5-mcrypt php5-mysql php5-cli php5-mhash php5-xsl php5-imap php$
Pin: release n=lenny*
Pin-Priority: 999

5. Install all related lamp package

#apt-get update
#apt-get clean#apt-get install libapache2-mod-php5 php5-common php5-curl php5-gd php5-mcrypt php5-mysql php5-cli php5-mhash php5-xsl php5-imap php5-xmlrpc php5-sqlite

#apt-get install mysql-server

6. Add cache ( I use eaccelerator)

#cd /root
#wget -c
#apt-get install php5-dev make

#rm /usr/lib/php5/build/
#ln -s /usr/share/libtool/config/ /usr/lib/php5/build/

#rm /usr/lib/php5/build/libtool.m4
#ln -s /usr/share/aclocal/libtool.m4 /usr/lib/php5/build/libtool.m4

#cd /usr/share/aclocal
#cat lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 >> libtool.m4

#cd eaccelerator-
#./configure --without-eaccelerator-use-inode
#make install

Configuration :

#nano /etc/php5/conf.d/eaccelerator.ini



#mkdir -p /var/cache/eaccelerator
#chmod 0777 /var/cache/eaccelerator
#/etc/init.d/apache2 restart

Check through phpinfo().

Extra step to protect from php shell alike : (editing php.ini)

disable_functions = dl , exec , passthru , pcntl_exec , pfsockopen , popen , posix_kill , posix_mkfifo , posix_setuid , proc_close , proc_open , proc_terminate , shell_exec , system , leak , posix_setpgid , posix_setsid , proc_get_status , proc_nice , show_source , escapeshellcmd


I can get php application work with 5.2 environment 🙂

Switch to PHP 5.4 on BlueHost

I want to learn laravel 4 and find starter kit using github that combine many class from others plus twitter bootstrap.

As traits available on php 5.4 I decide to find a host that support that version. As  I have account on Bluehost I decide to try it. Bluehost provide php 5.2, 5.3 and 5.4. By default you’ll see php 5.2 but you can enable other version. Here’s how to do that :

1. Login to bluehost cpanel

2. Find PHP Config

The option under Software/Services



Choose PHP 5.4 (single php.ini) and click save settings.




3. Try login via ssh

ssh access not provided by default. You need to request it first via support.

PHP cli will follow the setting. Here’s my login before change the version :

Using username “myacc”.
[email protected]’s password:
Last login: Sun May 12 20:54:42 2013 from
[email protected] [~]# php -v
PHP 5.2.17 (cgi-fcgi) (built: Oct 29 2012 18:51:17)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
[email protected] [~]#

Here’s my login after change PHP version to PHP 5.4 :

Using username “myacc”.
[email protected]’s password:
Last login: Wed May 15 21:51:27 2013 from
[email protected] [~]# php -v
PHP 5.4.13 (cgi-fcgi) (built: Apr 5 2013 16:41:50)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[email protected] [~]#

As simple as 123 🙂

How to check status of dns propagation

Common task when move to new web hosting is changing ns server supplied by hosting company.

You must enter those ns to domain control panel and wait. In case of web transfer after where you hired by someone or they little bit worry about the process you can educate them by using these tools :

  1. ; this service will check latest ns server that work for a domain.
  2. free dns service ; you can use google public dns or opendns service.
  3. clean dns cache ; you can type ipconfig \flushdns under ms dos command prompt.

By use those tools you can show latest status of domain propagation. In case of slow respond from your dns given by your isp you can ask them to use no.2.

Happy transfering 🙂

A communication error occurred: “Operation timed out” Network Error (tcp_error)

A message came out when one “heavy” php script work :

Network Error (tcp_error)


A communication error occurred: “Operation timed out”
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
For assistance, contact your network support team.

Easy way to overcome this message is increase maximum execution time.

Create .htaccess file with this content :

php_value max_execution_time xxx

xxx in second, by default the value of this option is 30.

I try to change to 120 :

php_value max_execution_time 120

save the file and recheck it via phpinfo().

Upgrade and refresh WordPress file to do list

Today I move around 20 domain plus its content to new web hosting. Common process that should be accomplished :

On Old hosting account 

  1. Backup database
  2. Create archive of wordpress files + backup database
  3. Scp to new web hosting through ssh

On new hosting account

  1. Extract archive from scp
  2. Create database, user access to database and add user to newly created database.
  3. Import sql file (backup database) to new database.
  4. Edit wp-config.php 
  5. Edit ns record for domain and relax.

As I see on wp-config.php. This file not change from time to time. One of wp-config.php I see from old domain (registered on 2003) :

See that. No salt and no other option as I used to see on new install of wordpress. This file should be change to newest version. Simple way to do that is copy wp-config.php from newest installation and edit its content (specially credentials section). This word add more power and refresh the blog. I should add it to my to list from now on.



How many domain I can host for shared hosting account

That question came from my friend who decide to use paid hosting after get banned by free hosting provider.

My answer is : depend

If you have only one domain with huge traffic (term huge is more than 1k) then you’ll need to consider one account for one domain. But if you have around 100 uv / day for a domain then I suggest to host maximum 5 domain for one account.

Other factors need to concern are :

  1. Dynamic or static; dynamic type content like wordpress, joomla, drupal will consume more than static html.
  2. Number of process allowed; a few host will give you throttle that put your host in freeze mode. No more access to new visitor until big trafic go away.
  3. Cpu process; extensive resources also prohibited. Make sure to use minimum plugin and use 3rd party service like nrelate that store all related post of your blog on their server.
  4. Language version; people often unaware about php version they use on their shared hosting. Use newest but stable version like php
  5. CDN (content delivery network); use font from google, twitter bootstrap from cdn is faster then host it and serve it yourself.


Amazon vs Adsense : which one is the best

Which program should I choose? Google Adsense or Amazon affiliate.

That question asked by my friend who want to try make  money on internet. No simple answer for that question. He need upper layer knowledge for his question.

Know the process first!

Why I should choose that program : those programs is great since backup by big company (Google and Amazon). You can rest assured that you get your payment.

How do I get visitor for my blog / website : most traffic that convert (lead to sales or click) came from search engine (google, yahoo,bing etc).

What information they look for? in general people look for knowledge information or product information. Don’t mix it to get great result.

Laser focus on 3 things :

1. Get low competition but high demand information.

2. Create content that supply information demand.

3. Monitoring competition that may rise.

Full detail of process might be read on this pdf file (free download).

Using that knowledge I can make modifications to my fresh store builder and expand it to other region.




Not big as but really challenging since I do little effort for the site.

Now I’m working on new version of my own system based on knowledge from pdf and fresh store builder. I think this one will be good and utilize other resource (blogspot and wordpress based system too).

Summary :

– Google adsense is good for knowledge based information site/blog.

– Amazon is good for product based information site/blog.

– Don’t mix google adsense and amazon on single site/blog.

How to Move Domain from Godaddy to NameCheap

Domain and Hosting : an inseparable pair

To be able to show off your presence in internet world you need 2 basic things :

1.Domain name
2.Hosting Account .

Domain name is the address that we type in browser. For example;,, .

Hosting account is not visible to end user / audience. As long you can see the content of an internet address that mean the hosting provider work well and you’re on business. By default an hosting company will serve those things (domain name and hosting) and client just need to care about the content. In real life, domain name and hosting account might located in different location due to some reasons such as; domain price, hosting price, performance consideration and security.

My brother want me to extend his domain for next 1 year. I agree to help him but with one condition. I can change the registrar. He agree and I start working.

I like to try new thing, including domain move. In last move domain related experiment I move domain from register to godaddy.

Here the posts :

1. move domain from register to godaddy : part1
2. move domain from register to godaddy : part2

In this experiment I want to move a domain from godaddy to namecheap . I already have an account at namecheap and add fund too from my paypal account. You need to create an account at namecheap if you don’t have one by click here.

Unlock Domain and get EPP key at Godaddy

The aim of this task is simple; unclock domain for transfer and get authorization key / EPP key from godaddy as current registrar.

Login to godaddy and click Domain Management link.


Choose domain that you want to transfer out of godaddy.

Click once to get manage domain link. Click the link.


Free VPS for Forex Trading

I have chance to learn about forex from scratch and decide to use a vps due to speed requirement. My current connection not support me when I need to close order and requote often.

Fortunately I use forex broker that provide free vps with small requirement :

Available balance is $500

That amount is fair for me and since I also make profit from my trading I can reach that requirement easily.

In this post I will share how to activate free vps for forex trading provided by roboforex.

Get Free VPS for Forex Trading

1. Login to roboforex account

Make sure you already verified for 2 levels :

  • identity verification
  • phone verification

free forex vps verifification requirement

2. Click link “Your VPS 2.0 Server” under Profile menu

free forex vps link from profile


Step by step install WordPress Multi User : part 1

I have request to create wordpress multi site, one domain connected with other properties with blogspot, weebly etc together with other domain (.net .org and many more) .

I this post I just want to share how to create wordpress multi site that connect with other TLD.

I use these stuff :

Schema :
1. db1 for main domain -> use standard wordpress installation
2. db2 for portal address (subdomain of main domain) -> for use with main page for manage client site.
3. db3 for client site (TLD domain) and host everything.

Lets get start with installation steps for WordPress Multi User :

WordPress multi user that known as wpmu already merge into code so you only need latest version of wordpress from

1. Install standard wordpress from for main domain

easy as 123

2. Install wordpress for portal use subdomain of main domain.

Login to cpanel and click subdomains