change mysql data directory ubuntu 17.xx

NOTE: you can skip empty directory (/var/lib/mysql/mysql) creation script in ubuntu 17.xx version.

Then try to start mysql server. If fail then log messages are telling you that /usr/sbin/mysqld needs read (r) access to open /proc/14767/status, /sys/devices/system/node/ (trailing slash because it wants to read the directory), and /proc/14767/task/14767/mem. The file to edit is /etc/apparmor.d/usr.sbin.mysqld.

In my case I solved the problem by adding these lines somewhere in the middle (with two spaces in front of each):

/proc/*/status r,
/sys/devices/system/node/ r,
/sys/devices/system/node/** r,

Reload apparmor:

sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
sudo /etc/init.d/apparmor reload

After doing that, try starting MySQL, and if you get more errors, add those files too and try again.

In some case mysql may fail to start for assoc i/o error. So, you may need to disable this settings by adding following line into /etc/mysql/mysql.conf.d/mysqld.cnf


Another note about file permission of data directory is, “mysql” user should have permission into every directory of that path. Like if new data directory is “/media/myusb01/mysql-data” then “mysql” user should read access of “/media” folder and “/media/myusb01” folder and read write access at new data directory.

Hope mysql will start now.


network adapter at guest [ubuntu] while setup host only network at virtualbox

I’m trying to setup host only network at virtualbox by following

but facing to choice network adapter at guest [ubuntu]

To see a list of the adapters your virtual machine can access, use this:

ls /sys/class/net

This will show you the interface names. For example, with two network adapters set up, my Ubuntu guest looks like this.

eth1 eth2 lo

To see a list of active network with IP address assigned


So you can easily guess what network adapter should use for host only network.

Well in a brand new ubuntu machine the permanent network save is not work in the way described in that article. For this you need to install ifupdown or ifupdown2 package

apt install ifupdown2

After install execute following command

ifup eth1

Then reboot.

JavaScript class encaptulation

My favorite JavaScript class structure –

(function(exports) {
	"use strict";
	var mySuperDupparClassOfSHKR=function(pValue){
	var myPrivateValue;
		return this;
	var __construct = function(that, pValue) {
		return that.setValue(pValue);
		}(this, pValue);
	exports.SuperDupparClass = {
		create : function(pValue) {
			if(typeof pValue==='undefined') throw 'please provide a value, unable to continue...';
			return new mySuperDupparClassOfSHKR(pValue);

Usage as follows –

var myObj;
jQuery(document).ready(function($) {
		myObj=SuperDupparClass.create('any value');
		alert('ERR: '+e);


Install PHP-Redis on PHP5.6 Centos 7

Assume that PHP 5.6 installed and working properly.

Now execute following command

sudo yum install php56w-devel
sudo yum install git-core
git clone git://
cd phpredis/
sudo phpize
sudo ./configure
sudo make
sudo make install
sudo echo "">/etc/php.d/redis.ini
sudo apachectl restart

Its pretty simple!

PHP Archive (.phar) Attaching with ZF2

PHP archive aka phar is a stream wrapper which can serve any packaged PHP library efficiently.

To create a phar document for a library (not for web output or for cli executable) is simple as pie like –

$phar = new \Phar('target-location-where-to-save.phar', 
 FilesystemIterator::CURRENT_AS_FILEINFO |
 FilesystemIterator::KEY_AS_FILENAME, 'optionalPharAliasName');

After creating phar document, file can use to attach ZF2 standard autoloader as follows –

 'Zend\Loader\StandardAutoloader' => array(
   'autoregister_zf' => true,
   'namespaces' => array(

This works as simple folder of your file system. Easily distributable, packaged.

PHP Debug efficiently with debug_backtrace

Hello today I write a small function for debug your PHP code. Its simple but powerful –

 $bkTrace=function ($stack) {
 $output = '';
 $stackLen = count($stack);
 for ($i = 1; $i < $stackLen; $i++) {
 $entry = $stack[$i];
 $func = (array_key_exists('class', $entry)?$entry['class'].'\\':'').$entry['function'] . '(';
 $argsLen = count($entry['args']);
 for ($j = 0; $j < $argsLen; $j++) {
 $my_entry = $entry['args'][$j];
 if (is_string($my_entry)) {
 $func .= $my_entry;
 if ($j < $argsLen - 1) $func .= ', ';
 $func .= ')';
 $entry_file = 'NO_FILE';
 if (array_key_exists('file', $entry)) {
 $entry_file = $entry['file'];
 $entry_line = 'NO_LINE';
 if (array_key_exists('line', $entry)) {
 $entry_line = $entry['line'];
 $output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL;
 return $output;
 echo '<pre>'.$bkTrace(debug_backtrace()); exit();

Image size for social media (like facebook, twitter, google+, linkedin, pinterest, instagram, youtube) profile and other picture

As we faced many problem to work in social media about size of profile picture to use. Here is the dimension that analysis by renowned email marketing tools provider constant contact. Also I add some value to enrich the list –

Cover photo 815×315
Profile photo 180×180 (display area 160×160)
Fan page profile photo 200×200 (display area 176×176)
Tab 111×74
Link Image 1200×627
Image 1200×1200
Highlighted/milestone image 1200×717

Header 1500×500
Profile photo 400×400
Image display size 880×440 (recommended)

Profile photo 250×250
Cover photo 2120×1192
Shared image 800×600

Profile photo 200×200
Cover photo 646×220

Profile photo 600×600
Board thumbnail 222×150

Profile photo 161×161
Image viewed on desktop in lightbox as 612×612
Image feed 510×510

Profile photo 800×800
Channel art 2560×1224
Custom video thumbnail 1280×720

* all dimensions listed in pixels

Hope it may help you to engineering the web for your client.

Batch file that will create skeleton directories of ZF2

After a long time write a batch file to create a skeleton directory for Zend Framework 2 module. Hope it may help someone who work in windows 7 OS

@echo off
@rem this file will create required empty directory of a ZF2 module
@rem author Shahadat Hossain Khan (
IF "%~1"=="" GOTO noModuleName
SET modName=%~1
CALL :UCase %modName% _UCMN
CALL :LCase %modName% _LCMN
 MKDIR %_UCMN%\config
 MKDIR %_UCMN%\src
 MKDIR %_UCMN%\src\%_UCMN%
 MKDIR %_UCMN%\src\%_UCMN%\Controller
 MKDIR %_UCMN%\src\%_UCMN%\Form
 MKDIR %_UCMN%\src\%_UCMN%\Model
 MKDIR %_UCMN%\view\
 MKDIR %_UCMN%\view\%_LCMN%
 MKDIR %_UCMN%\view\%_LCMN%\%_LCMN%
 ECHO Directory created. Named - %modName%
) else (
 ECHO Directory already exist!
ECHO You must provide module name along with this command as 1st argument

:: Syntax: CALL :UCase _VAR1 _VAR2
:: Syntax: CALL :LCase _VAR1 _VAR2
:: _VAR1 = Variable NAME whose VALUE is to be converted to upper/lower case
:: _VAR2 = NAME of variable to hold the converted value
:: Note: Use variable NAMES in the CALL, not values (pass "by reference")
set varX=%1
set frstChar=%varX:~0,1%
set rstChar=%varX:~1%
FOR %%Z IN (Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx 
Yy Zz) DO (
 SET pX=%%Z
 set c1=!pX:~0,1!
 set c2=!pX:~1,1!
 IF /I "%0"==":UCase" (
 if %frstChar%==!c1! SET _Abet=!c1!
 if %frstChar%==!c2! SET _Abet=!c1!
 IF /I "%0"==":LCase" (
 if %frstChar%==!c1! SET _Abet=!c2!
 if %frstChar%==!c2! SET _Abet=!c2!
SET _Word_Rtrn=%_Abet%%rstChar%
SET %2=%_Word_Rtrn%



<your batch file name> <the module name>

Install Zend Framework 2 into Windows IIS

This article will show you how you can install Zend Framework 2 into your windows OS without composer.phar help.

1. Download latest stable copy of ZF2 from and unpack, we call it ZF2

2. Download latest stable copy of ZF2 skeleton app from and unpack, we call it ZF2Skeleton

3. Create folder like <ZF2Skeleton folder>/vendor/ZF2. Now copy ZF2/* into <ZF2Skeleton folder>/vendor/ZF2 And the final directory structure may look like following image (for ZF2 version 2.3.1 dated 20140426)

zf2 basic folder structure

4. Now point any domain into “public” folder. e.g. zf2.localhost.tld

  • 4.a. Open notepad as administrator user
  • 4.b. Add an entry to your hosts (file) like – “ zf2.localhost.tld” [one host in each line]
    • 4.b.1 hosts file is typically located at C:\WINDOWS\system32\drivers\etc\hosts
  • 4.c Now save the hosts file and close
  • 4.d. Now create an entry in your IIS (6 or 7 both are same procedure) by following with the above host name i.e. zf2.localhost.tld

5. Now you need to fix ZF2_PATH or $zf2Path variable at “/init_autoloader.php” file of root to point our “/vendor/ZF2” folder

Find following code:

$zf2Path = false;
if (getenv(‘ZF2_PATH’)) { // Support for ZF2_PATH environment variable
$zf2Path = getenv(‘ZF2_PATH’);
} elseif (get_cfg_var(‘zf2_path’)) { // Support for zf2_path directive value
$zf2Path = get_cfg_var(‘zf2_path’);

Replace by following code:

define(‘APP_ROOT_PATH’, dirname(__FILE__).DS);
$zf2Path = false;
if (is_dir(APP_ROOT_PATH.’vendor’.DS.’ZF2′.DS.’library’)) {
$zf2Path = APP_ROOT_PATH.’vendor’.DS.’ZF2′.DS.’library’;
} elseif (getenv(‘ZF2_PATH’)) { // Support for ZF2_PATH environment variable or git submodule
$zf2Path = getenv(‘ZF2_PATH’);
} elseif (get_cfg_var(‘zf2_path’)) { // Support for zf2_path directive value
$zf2Path = get_cfg_var(‘zf2_path’);

You can now visit zf2.localhost.tld to get your expected site.

Please note, you must run latest copy of PHP (at least bigger then 5.3.23 when I write this article there I found version 5.3.28 stable for windows non thread safe version installer for download) from

Now the problem is URL route in IIS. That means when you lookup into ZF2 getting started docs you may find some code to edit .htaccess of apache. What about IIS in this case?

IIS have solution of URL rewrite problem. Visit to get the latest copy of the plugin to attach into your IIS installation. Just install this addon/plugin/extension/demon/program whatever name you called.

After installation you need a file web.config into your “<ZF2Skeleton folder>/public” folder. No matter, here we do a small trick. Just download Drupal 7+ core from and unpack it. There you found a web.config file at root path. Just copy and paste that file into your <ZF2Skeleton folder>/public folder.

That’s all folk!

ckeditor installation into drupal with imce

As a professional app developer, I faced to install ckeditor into drupal many times. Each times I need to dig again and again to its working. So, now I think I have to write it down that will help me and others too 😉

Install ckeditor into Drupal with IMCE

Its simple two step > Download & Put it into right place, Configure & use.

Download & Put it into right place

1. Download Drupal module of ckeditor from
2. Download Drupal module for IMCE from
3. Put those module into “sites/all/modules” folder or where you think appropriate
4. Now download full version of ckeditor from
5. Put full version of ckeditor into “<path where you put your ckeditor drupal module>/” please visit for details instruction where to put

That’s it, you are done the first step

Configure & use

Now enable that two module from your Drupal control panel.

1. Fix permission for ckeditor
2. Configure IMCE
3. Configure text format – Administration > Configuration > Content authoring > Text formats
3.a) For Advanced Html >> enable filter “limit allowed html tags” and leave it as it is or put “<a> <p> <div> <h1> <h2> <h3> <img> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <em> <b> <u> <i> <strong> <del> <ins> <sub> <sup> <quote> <blockquote> <pre>” allowed or as your requirement
3.b) For Full Html >> enable filter “limit allowed html tags” and put “<a> <abbr> <acronym> <address> <area> <article> <aside> <audio> <b> <bdo> <bgsound> <big> <blockquote> <br> <br /> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <command> <datalist> <dd> <del> <details> <dfn> <div> <dl> <dt> <em> <fieldset> <figcaption> <figure> <font> <footer> <form> <h1> <h2> <h3> <h4> <h5> <h6> <header> <hgroup> <hr> <hr /> <i> <img> <input> <ins> <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <marquee> <menu> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <rp> <rt> <samp> <section> <select> <small> <source> <span> <strong> <sub> <summary> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <time> <tr> <tt> <ul> <var> <video> <wbr>” allowed or define tag to allow as your requirement
4. Now configure ckeditor. Specially for file browser settings. Point it to IMCE. Please configure both profile (Full, Advanced)

That’s it. nJoy….

« Older entries