How to change timezone in Ubuntu / Debian from command-line

This guide assumes that you use Ubuntu or Debian-based GNU/Linux distro. There are two ways to change timezone from bash command line.

sudo dpkg-reconfigure tzdata

or,

sudo ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

You can also specify other timezone in the second method, for example:

sudo ln -sf /usr/share/zoneinfo/GMT /etc/localtime

or for Eastern Standard Time (US)

sudo ln -sf /usr/share/zoneinfo/EST /etc/localtime

This command is handy when administrating multiple servers across different continents.

How to Optimize and speed up PHP with OPCache

PHP 5.5 and 5.6 comes with OPCache. OPCache speeds up PHP execution by storing precompile bytecode of PHP in shared memory. Taking advantage of fast memory operations compared to hard disk operation, OPCache eliminates the process of having to read PHP scripts from the disk each time whenever a script must be executed.

In short, OPCache saves the time needed to serve PHP-powered websites!

How to enable OPCache?
This tutorial is written from Ubuntu 14.04 LTS standpoint – using php5-fpm, but it should also work for other Linux distro.

  1. First edit ‘/etc/php5/fpm/php.ini‘ file.
  2. Find “opcache” section in the PHP ini.
  3. Uncomment and change opcache.enable to opcache.enable=1
  4. Do the same for >opcache.memory_consumption, changed its value from 64 to 128 (or 256)
  5. Change opcache.interned_strings_buffer from 4 to 16
  6. Changed the opcache.max_accelerated_files to 8192

Activate OPCache with php5enmod command.

sudo php5enmod opcache

Save file and restart php5-fpm.

sudo service php5-fpm restart

PHP OPCache should be running on your server now. Here’s a reference of /etc/php/fpm/php.ini file in Ubuntu 14.04 LTS.

[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=0

; The OPcache shared memory storage size.
opcache.memory_consumption=128

; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=16

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=8192

BONUS: How to verify whether PHP OPCache is running ??
You can verify whether OPCache is running by using opcache-status by Rasmus Lerdorf. Just drop the script in one of your web directory and browse. If you’re not a Git fan, I’ve also have taken the liberty of mirroring the download: opcache-status.zip

opcache-status screenshot
opcache-status-ss

How to check if your website supports SPDY 3.1

Although Google has announce to drop SPDY support by early February 2016 in favor of HTTP/2, SPDY remains the best HTTP protocol extension to maximize compression and reduce webpage load latency.

The current and final SPDY implementation supported by Mozilla Firefox and Google Chrome is SPDY/3.1.

In order to check if your webserver supports SPDY 3.1, just simply:

  1. Go to your website, eg: https://blog.mypapit.net/
  2. Using Chrome, type – “chrome://net-internals/#spdy” at the addressbar
  3. You should see your website name and spdy/3.1 protocol listed, refer to Screenshot below

spdy

Additionally, you could go to spdycheck.org to check if your web server supports SPDY.

Have fun!

Tips for Securing SSH in Linux Box (Securing SSH Series)

Secured Shell or SSH is a great way to enable a secure login for your UNIX / Linux Box. However there are precaution that you should take in order to properly secure SSH daemon from being scanned or attacked by script kiddies or automated bots.

This week I’m going to write a series of article on securing SSH on Ubuntu Linux Box (VPS) and I’m going to link to this post from time to time.

  1. Disable Root login, enable SSH login for a handful of users only
  2. Install and configure Fail2Ban
  3. Limit access with Firewall Rules (limit by ip block, or ip address)
  4. Limit connection rate to SSH port
  5. Disable keyboard interactive login, Use public-key login
  6. Security Security through obscurity: Hiding SSH version
  7. Security Security through obscurity: Change default SSH ports

Hope this will help in securing your Linux Box / Linux VPS

Top 5 things I do with my Ubuntu Linux

I haven’t had much time since I migrated my blog to a new VPS server. However, here is a little treat for all my readers out there. The top 5 things I do with my Ubuntu Linux:

  1. Surfing the internet
    Pretty obvious – I usually surf the internet using my Ubuntu Linux on my Desktop computer. I’ve a dual-monitor setup computer with Intel Core i5 CPU (12GB RAM), It is not a gaming pc, but I do occasionally play DOSBox games as well as Need For Speed: World from another operating system. The seamless Unity integration with the web intrigues me though, wished I had touchscreen monitor
  2. Developing Android Application
    The qemu-based Android device emulator runs nicely on Ubuntu, with no sign of lagging presents in other operating systems. Plus with 12GB of RAM, I can say that I could study and do mobile application with relative comfort. For Android 4.x development, I prefer to use the x86 images, because put less contraint on the CPU for skipping ARM-related code translation.
  3. Torrents
    Usually this is being done in parallel with other works. My current favorite bittorent client is Deluge. For some reason, I find Azureus/Vuze too cumbersome and I haven’t got around to use Transmission. I used to study bittorrent protocol in my spare time, but has since abandoned it when I realise that I’ve not much time to spend on side-projects anymore.
  4. Writing Manual
    I’m now in the process of writing a Lab Manual for those who just begining to learn about Mobile Computing. Although I wouldn’t call myself as an expert, I think every little bit of knowledge-sharing helps. I’ll promise I’ll share my progress with all of you sometimes at the end of the year. Though, I usually prepare my academic papers using Latex (IEEE templates), I choose to write my manual in LibreOffice, for reasons that I’m more familiar with WYSIWYG word-processor, plus, the publisher would prefer to receive the written manuscript in OpenDocument or Microsoft OpenXML file.
  5. Internet Radio
    Though I rarely if ever listen to MP3 in portable devices, I do listen to internet radio station from Rhythmbox. There are sizeable collection of preset Internet Radio station in Rhythmbox according to genre and age-group. I prefer to listen to trance or easy-listening radio stations.

There you go, the top 5 things that I usually do with my Ubuntu Linux. Nothing fancy, just that I prefer to use Ubuntu for reasons of application development. I’m a terminal-emulator typed guy. I prefer to switch/change the environmental settings using terminal emulator, something I find very easy to do in Ubuntu (or any GNU/Linux distribution for that matter).

Until next time…

No Official pre-press Ubuntu 13.04 CD/DVD will be distributed by Canonical

Previously as an effort to promote Ubuntu and Free Software, Canonical has made pre-pressed CD/DVD available for LoCo team to be distributed during release party or promo events.

But starting from Ubuntu 13.04 (Raring Ringtail), pre-pressed Ubuntu CD/DVD will only be made available only for LTS release (the next one will be 14.04 LTS ) from this point forward. This is in-line with Canonical policy to only concentrate on supporting Ubuntu LTS.

In the mean time, Canonical will continue to provide pre-pressed Ubuntu 12.04 LTS CD/DVD to Ubuntu LoCo until 14.04 LTS release in 2014.

source: Ubuntu Loco Council