Web Server build in a minute on Ubuntu Machine

I guess, you want to make your Ubuntu server UP & running within few minutes with one click that will install all the essential packages for your web server. I created the following script that you can run right after installing your Ubuntu OS in your machine.

I tested this script over Ubuntu 14.04 LTS and nGinx as web server.

I created the following shell script for (a) Installing Common packages, (b) Configuring Virtual Host

You just need to run the installer. In your terminal just write down the following command and it will start installing all the essential thing and after that browse localhost or with server IP address and you are supposed to see the default nginx server page.

sudo wget https://gist.githubusercontent.com/shahariaazam/b63b72da0afbff195492/raw/db0ff5f553fdb25cf3bd9da64ec942cf09b31ab7/make_ubuntu_ready.sh
sudo chmod a+x make_ubuntu_ready.sh
sudo ./make_ubuntu_ready.sh

And browse ‘http://localhost’

You can explore the shell script from the following gist. First file is the shell script that you are installing in above command prompt. Second and third .conf file is for sample virtual host. I embeded those 3 files for you to look at. If you think that we can add any more things please write here in comment box so I will consider that for others.

Published on 31 Aug 2015 » »

Fast startup turn on or off in windows 10

Today is my first day in my machine to work in Windows 10. And my machine has Windows 10 installed alongside Ubuntu 14.04 LTS. But I faced my very first problem with Windows 10 today that was related to NTFS drive mounting from Linux. At last I figured out the problem.

If you use Windows 10 and Linux in same machine then when you will use Windows 10, by default Windows 10 has Fast startup turned on and that will prevent mounting your Hard disk again from Linux OS. So in that case you have to turn of the Fast startup option from your Windows 10 so you can again mount your hard disk from your Ubuntu Machine.

This is very pretty simple thing. See the following screencast and turn of Fast startup from your Windows 10 machine. Screencast link on Youtube. Here is the link: https://www.youtube.com/watch?v=1uZU9OwjebI

Published on 31 Jul 2015 » »

Google Mobile-friendly test in PHP

Lots of folks out there about to make your website Mobile-friendly. It’s obvious that there will be significant impact on your website if your site is not mobile-friendly or what we regularly call ‘responsive’. Mobile friendly sites will get higher rank in search results in Google. And Google already started to rolling out this algorithms.

After searching on internet, I didn’t get any quick solution to check mobile-friendliness website in PHP. Although Google published it’s official Mobile-friendliness Test Tools.

When I tried to find some solutions then I figured out that Google has it’s public Pagespeed Test API v2. But in this version Google didn’t make it clear to see Pass or fail result for mobile-friendliness test. It only shows UX score. But in their v3beta1 API version they have a clear indicator about mobile-friendliness. And I figured it out and made a simple PHP functions to check the mobile-friendliness test of any website. Here is my scripts:

In the above script you just need to put your website URL to check and Google PageSpeed API Key what you will get from your Google API Console or see the Google PageSpeed Developer Getting Starter page.

Now, run your script and you will get the following array.

array (size=8)
  'kind' => string 'pagespeedonline#result' (length=22)
  'id' => string 'http://facebook.com/' (length=29)
  'responseCode' => int 200
  'ruleGroups' => 
    array (size=1)
      'USABILITY' => 
        array (size=2)
          'score' => int 100
          'pass' => boolean true
  'pageStats' => 
    array (size=2)
      'numberRobotedResources' => int 0
      'numberTransientFetchFailureResources' => int 0
  'formattedResults' => etc.........

From the above array $result['ruleGroups']['USABILITY']['pass'] is the actual result of your website’s mobile-friendliness status. true means your website is mobile friendly and false means your failed to make your website mobile friendly. Simple.

Have fun! Write comments if you need any more assistance.

Published on 09 May 2015 » »

Twig and AngularJS curly braces conflict solution

Whoever loves to work with Twig template system for their PHP driven web application may want to implement AngularJS within Twig template. But the main problem will be Twig’s curly braces. AngularJS and Twig both use __ inside their template to output data. So simply, it can cause trouble to work with this two lovely systems together in your application.

But here is the solution. According to AngularJS $interpolateProvider docs I figured out the easy solution. You can change AngularJS __ symbol with any other symbol. Cool! So see how you will override that configuration.

var app = angular.module('myApp', []);


Now you can use {[{ }]} symbol for your AngularJS. And Twig use **. So problem solved. From now on you can use AngularJS within your Twig template system.

Published on 14 Apr 2015 » »

AngularJS Resource use for RESTful apps

This example will help you to learn how to interact between your backened RESTful apps and AngularJS. AngularJS has a service factory called ngResource which you can use to do CRUD operation with your RESTful backend application.

Here you just need to define the service factory which will get all notes by calling an ajax request to your http://yourRESTAPIBackendserver.url/notes. Also you can do rest of the CRUD services with that script. This script represents very basic usage of ngResource. So you learn it and try to DYI.

Don’t forget to add the main angularjs library and ng resource service library in your html head tag.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://code.angularjs.org/1.2.0-rc.2/angular-resource.js"></script>

Published on 14 Apr 2015 »

Post Form Data via JQuery-Ajax Post

Case Scenario Want to prevent default HTML form submission behavior and want to post form data via jquery & ajax to any URL.

Solution Very simple solution. just with e.preventDefault() prevent default form submission and write down the following jquery code and enjoy!

Thanks. Post a comment if you face any problem.

Published on 31 Mar 2015 »

MikroTik NAT Port Forwarding - Access local pc from internet

Let me first tell you the real case scenario for this solution.

Case 01

  • You have a local network that is designed and attached with a MikroTik router that is easily managable. You have multiple computer in your local network that is running different types of applications or services. Your MikroTik router is also connected with a public ip provided by your ISP. Now you want that one of your local computer will be accessible via internet through that public ip. So in this case you can build web server, you can run mail server, you can run ftp server, other services, etc.. etc.


  • After solving this with this article anybody from internet (or whoever you give access) can access your local pc ( or any local computer) from internet.


  • First let me describe you the visual design of network design in your home or office. See Figure: A-1.

MikroTik NAT Port Forwarding example - Access Local PC from Internet

Your Public IP is which was provided by your ISP and attached with your MikroTik router. And your local pc’s are,,,

Now in your pc is running your web server and you want to make it accessible from outside your network that means from internet. Now open your winbox and connect to your router.

  • Go to IP -> Firewall-> Select NAT Tab

MikroTik NAT Port Forwarding example - Winbox configuration 1

From General tab Select dstnat chain. From Protocol select tcp. From Dst. Port right down the port with which port the remote request will be connect. Here for web server I did 8080.

MikroTik NAT Port Forwarding example - Winbox configuration 1

Now go to Action tab and select Action to dst-nat, In ToAddresses select and To Ports will be 8080. Now save that settings. When you want to access web server from internet people can do that by hitting and that will be connected back and forth with

Published on 24 Feb 2015 »

Enable Debug mode in Twig Template

Sometimes you need to see your variables or object in Twig template before printing it out. So to enable debug mode in twig template system you just need to tweak few settings upon initializing twig environment. Just follow the below code where I initiated Twig environment with debug mode.

$twig = new Twig_Environment($loader, array(
    'debug' => true,
    // ...
$twig->addExtension(new Twig_Extension_Debug());

And inside your template where you want to dump the variable just write ``. You can read more about dump function twig template from here

Published on 17 Feb 2015 » »

Some Important MikroTik Tips and Tricks

Port Forwarding to local IP/PORT

Type the following value into a Terminal window to enter this port forwarding rule.

bash /ip firewall nat add action=dst-nat chain=dstnat disabled=no dst-port=80 in-interface=ether1-gateway protocol=tcp to-addresses= to-ports=80

In the above MikroTik NAT forwarding rule add through MikroTik RouterOS terminal what I am doing with the above command? We are just forwarding any kinds of request to our main IP in 80 and forwarding that connection to ip which is in my local network and port 80 will be used from for that request.

Published on 10 Feb 2015 »

Create INI file in PHP

Write configuration data in a .ini file in PHP. It’s important for large application to store global configurations about the whole/partial system for applications.

Published on 25 Sep 2014 »

Pages »