How to test VPS Speed and Performance?

wget -O - -o /dev/null | bash

How to Benchmark VPS

How to Benchmark VPS

How to Test VPS Download and Upload Speed

python --share

How to Test VPS Download and Upload Speed

How to Test VPS Download and Upload Speed

How to Test VPS Disk I/O Performance

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

How to Test VPS Disk I/O Performance

How to Test VPS Disk I/O Performance

How to Clone / Download / Mirror a Website using WGET

This is a quick and dirty way to clone, download or make a mirror of a website for offline reading. We only need WGET. It will download all images, CSS and Javascript files

wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains --no-parent

By default, wget also has an option to do mirroring.

wget -m

In order to avoid your IP getting banned or blacklisted by the server, try to add this options:

--wait=9 --limit-rate=10K

Hope it helps. :)

How to Solve XAMPP Problem Port 80, 443 in use by Skype

I’m trying to start XAMPP Control Panel, but I got these error messages:

Port 80 in use by "c:\program files (x86)\skype\phone\skype.exe"!
Port 443 in use by "c:\program files (x86)\skype\phone\skype.exe"!

XAMPP Problem - Port 80, 443 in use by Skype
The easiest way to solve this XAMPP problem is shutdown your Skype, and restart your XAMPP Control Panel. But that is not a smart solution.
So how to solve this port in use issue? In Skype Options: [Connection] , there is a check-box labelled Use port 80 and 443 as alternatives for incoming connections. This is the root problem, so simply clear / unchecked it and save. You may need to restart Skype.
Skype - Use port 80 and 443 as alternatives for incoming connections
Restart your XAMPP Control Panel, and the error message is now gone! Try to start Apache, and succeeded. :)
XAMPP Control Panel - Apache is Running

What if the port is not used by Skype, but by other applications such as TeamViewer? If so, then XAMPP have to use another port.

How to change Apache default port in XAMPP?

From XAMPP Control Panel, under Apache, click the Config button, and select the Apache (httpd.conf).
XAMPP Control Panel - Apache config port
Inside the httpd.conf file, find line that says

Listen 80

And change the 80 into any number / port you want. In this example I’m using port 8080.

Listen 8080

Still from the httpd.conf file, find another line that says

ServerName localhost:80

And change 80 to 8080.

ServerName localhost:8080

Next step, still from XAMPP Control Panel, under Apache, click the Config button again, but this time select the Apache (httpd-ssl.conf). Inside the httpd-ssl.conf file, find line that says

Listen 443

And change the 443 into any number / port you want. I’ll using 4433 as the new port number.

Listen 4433

Still from the httpd-ssl.conf file, find another line that says

<VirtualHost _default_:443>
ServerName localhost:443

And change 443 to 4433.

<VirtualHost _default_:4433>
ServerName localhost:4433

Remember to save httpd.conf file and httpd-ssl.conf after you make some changes.
Now it’s time to fire-up our Apache in XAMPP Control Panel. If your doing good on editing those files, you should see that Apache is running and the port number has changed to 8080 and 4433.
XAMPP Control Panel - Change Apache default port number

How to Solve ORA-12162: TNS:net service name is incorrectly specified

This morning I try to import an Oracle dump file, but I got this error message:

ORA-12162: TNS:net service name is incorrectly specified

Some people says that there’s something wrong with the tnsnames.ora file. But I’ve checked it, and the file looks fine.

After googling for a while, I found that this error message showed up because we haven’t set the ORACLE_SID or maybe have the value set improperly.

So, if my SID is dbnew, then I type this command on my Ubuntu:

export ORACLE_SID=dbnew

If you’re using Windows, type this:

set ORACLE_SID=dbnew

Don’t forget to change the dbnew to your own SID name.

Hope it helps. :)

How to Solve WARNING clock of the subversion server appears to be out of sync

When I tried to build project from Subversion in Jenkins, I got these error messages:

WARNING: clock of the subversion server appears to be out of sync. This can result in inconsistent check out behavior.

So, after googling for a while, the easiest solution was add @HEAD at the end of the Repository URL.

For example, if your Subversion Repository URL was:

All you need to do is simply add @HEAD at the end of the URL. So it become like this:

Hope it helps. :)

Ubuntu 12.04 Can’t Login to Desktop unless using Guest Session

After re-installing my PC using Ubuntu 12.04, I always do sudo apt-get update and sudo apt-get upgrade, so my system is always up to date.

But after I do this sudo reboot, I can’t login to my Ubuntu 12.04 desktop.

Then I try to login to my PC using PuTTY from my Windows laptop. The result is I can logged in to my Ubuntu 12.04 machine. It means that the password I entered is correct, and there’s something wrong with my Ubuntu.

After googling for a while, I found out that there are many users out there that had the same problem as me.

The solution that worked for me is rename or delete .Xauthority file located on your home directory. As for me, it’s located in /home/wks-403/.Xauthority. Yours may be vary.

So here’s what I do. I logged in to my Ubuntu 12.04 using PuTTY from other machine, and I delete that .Xauthority file.

sudo rm /home/wks-403/.Xauthority
sudo reboot

That’s it. After rebooting my Ubuntu 12.04, I can log in again to my desktop.

PS: if you don’t have other machine to logged in from, you can also using Ubuntu Live CD or USB flash disk.

How to Extract / Uncompress 7z Files on Ubuntu

I’d like to import a database dump file, but it’s compressed in 7zip format (7z). So I need to extract that 7z file using 7za. 7za is included in p7zip package.

First we need to verify whether we have 7za installed or not.

whereis 7za

If you see something like:

7za: /usr/bin/7za /usr/share/man/man1/7za.1.gz

It means 7za is already installed on your system. But if you see nothing like above, then you must install p7zip package.

How to install p7zip to extract 7z files on Ubuntu

sudo apt-get install p7zip

How to Extract / Uncompress 7z files on Ubuntu

7za e my_source_file.7z

It means we will extract / uncompress the my_source_file.7z.

How to Create a 7z files on Ubuntu

7za a my_target_file.7z my_source_directory/

It means all files and sub directories of my_source_directory/ will be added to the my_target_file.7z.

How to Setup WordPress Multisite with Subdomain

How many blogs do you have? Have you ever feel bored when it’s time to update wordpress, themes and plugins, because you have to do it one by one? Do you want to have your own blog network, like If yes, then I think you should consider to setup a wordpress multisite.

Step by step to setup a wordpress multisite

I assumed we’re using a fresh install wordpress, so we don’t have any datas to backup. Also I’m using cPanel as an example.

  • Create a wildcard subdomain
    Create a Wildcard Subdomain

    Create a Wildcard Subdomain

  • Create a wildcard DNS A record. Go to Simple DNS Zone Editor, select the domain name, put * (wildcard) as Name, and your web hosting IP address as the Address.
    Create a Wildcard DNS

    Create a Wildcard DNS

  • Edit wp-config.php, add these lines above the line that says
    /* That's all, stop editing! Happy blogging. */

    So your wp-config.php file become like this:

    /* Multisite */
    define('WP_ALLOW_MULTISITE', true);
    /* That's all, stop editing! Happy blogging. */
  • Refresh your wordpress dashboard. Go to Tools menu and you should see a new menu called Network Setup
    Wordpress - Tools - Network Setup Menu

    WordPress – Tools – Network Setup Menu

  • Previously, we already setup the Wildcard Subdomain and Wildcard DNS, so for the Addresses of Sites in your Network, select the Sub-domains
    Addresses of Sites in your Network

    Addresses of Sites in your Network

    Make any other necessary changes, and click the Install button.
  • If you see some warning messages like this one, just ignore it, because we already configured our Wildcard DNS.
    Warning! Wildcard DNS may not be configured correctly!

Enabling the Network

Complete the following steps to enable the features for creating a network of sites.

Caution: We recommend you back up your existing wp-config.php and .htaccess files.

  1. Create a blogs.dir directory at /home/<hostname>/public_html/<>/wp-content/blogs.dir. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.

  2. Add the following to your wp-config.php file in /home/<hostname>/public_html/<>/ above the line reading /* That’s all, stop editing! Happy blogging. */:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', '<>');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
  3. Add the following to your .htaccess file in /home/<hostname>/public_html/<domain.ext>/, replacing other WordPress rules:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]

Once you complete these steps, your network is enabled and configured. You will have to log in again.

How to Allow New Registration in WordPress Multisite

Go to Network Settings » Registration Settings » Allow new registrations, select the Both sites and user accounts can be registered.

Wordpress Multisite Allow New Registrations

WordPress Multisite Allow New Registrations

That’s all folks. Your very own wordpress multisite with subdomain is now ready. Hope it helps. :)

How to Setup a VPS using Debian 6 Linux (32 Bit)

Why do I choose Debian? Well, beside it’s “pretty easy” to setup, I think Debian is more stable than the other linux distros. But why 32 Bit? Because I think 32 Bit OS is using less memory than the 64 Bit.

VPS Minimum Security Settings

What I do for the first time is add a new non-root user, and set BASH as its shell.

adduser --shell /bin/bash johndoe

Next, I’m gonna change the default SSH port that is 22 into a new number above 1024 and below 65535. Then I’ll disable root logins over SSH. In order to do that, we need to edit the sshd_config file located in /etc/ssh/sshd_config. I’m using pico as the text editor.

pico /etc/ssh/sshd_config

To change the port number, find this line:

Port 22345

To disable root logins, find this line:

PermitRootLogin no

Then restart the SSH service.

service ssh restart

Now, you need to logout from root, and re-login using new user that you just created before.

After we logged in as a normal user, and if you need a root privileges, you can use su command:

su -

Congratulations! You just finished the minimum security settings of your VPS.

Getting Updates for VPS from Repository Server

As root, open the sources.list file, located in /etc/apt/sources.list

pico /etc/apt/sources.list

Edit or replace all of the existing lines with these lines:

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

Proceed the update.

apt-get update && apt-get upgrade -y

After the update process completed, I wanna change the default timezone of my VPS.

dpkg-reconfigure tzdata

Install vnc4server and web browser on VPS

This command will install an xserver, vnc4server and iceweasel browser also flash plugin.

apt-get install -y --no-install-recommends xserver-xorg-core xfonts-base xterm jwm menu vnc4server iceweasel flashplugin-nonfree

Now let’s try to run the vnc4server. You can also change the geometry to 1024×768, and depth to 24.

vnc4server -geometry 800x600 -depth 16

Since it’s the first time you’re running vnc4server, you will be asked for a password. That password will be used for accessing your desktop using VNC viewer.

Open your VNC viewer and connect to your VPS. I’m using RealVNC. Set the “VNC Server” to your VPS IP address and add :1, example:

To stop vnc4server, type this command:

vnc4server -kill :1

You may want to know how to run vnc server at startup / boot and also how to restart vnc server hourly using crontab.

What if I wanna run Firefox browser each time my VNC server is up? Sure you can. Just edit xstartup file located on your username VNC folder. If your username is root, then the xstartup file is in /root/.vnc/xstartup

pico /root/.vnc/xstartup

add new line:

firefox --display=:1 -private &

Download Firefox 3.6.28 and replace iceweasel as default web browser

In this example, I downloaded the Firefox into /root folder, and extract it into /opt folder. You can always change it if you want.

wget -O /root/firefox-3.6.28.tar.bz2 && cd /opt && tar xjvf /root/firefox-*

Edit the firefox script:

pico /usr/bin/firefox
  • --> comment line:
    #exec iceweasel "$@"
  • --> add new line:
    exec /opt/firefox/firefox "$@"
update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/firefox 100
update-alternatives --set x-www-browser /usr/bin/firefox

How to restart your VPS daily

Simply add a new cron job. Open your crontab:

crontab -e

Add this line:

59 23 * * * /sbin/shutdown -r now

That means, your machine will be rebooted everyday at 23:59.

How to Restart VNC Server Hourly using Crontab

Sometimes I need to restart my VNC server periodically, usually hourly. So I’m gonna need crontab. In some conditions, the killing process of VNC server may still leaves some files on the VNC folder or inside temp folder. So, before we start the VNC server again, we have to make sure that those files are deleted.

Open your cron job

crontab -e

Add these lines:

1 * * * * vncserver -kill :1 && rm -rf /root/.vnc/*.pid && rm -rf /root/.vnc/*.log && rm -rf /tmp/.X11-unix/X1 && rm -rf /tmp/.X1-lock
2 * * * * vncserver

You may need to adjust the value of this /root part. This is where the files are located. If you’re running VNC server as a different user, such as johndoe, then the files maybe located in /home/johndoe