Installing Nginx in Mac OS with home brew

Install with brew

Use brew to install the nginx with command:

$ brew install nginx 

After install run:

$ sudo nginx 


Test it by going to URL:



The default place of nginx.conf on Mac after installing with brew is:


Changing the default port

The nginx default port is 8080, we shall change it to 80. First stop the nginx server if it is running by:


$ sudo nginx -s stop 

Then open nginx.conf with:


$ vim /usr/local/etc/nginx/nginx.conf 

and change the:


server {  listen 8080;  server_name localhost;   #access_log logs/host.access.log main;   location / {  root html;  index index.html index.htm;  } 



server {  listen 80;  server_name localhost;   #access_log logs/host.access.log main;   location / {  root html;  index index.html index.htm;  } 

Save configuration and start nginx by

$ sudo nginx 

Changing the path of defualt web location

The nginx html folder (brew install only) is by the defult in:


Note: change 1.2.3 to your nginx version.

The defualt path configuration:


Installing Cassandra In Mac OS X ‘Mavericks’

First, you need Java 7 JDK, not to be confused with JRE. Cassandra won’t run without it. So run a java -version command before you proceed.

I used brew to install and maintain it for me ;-)

brew install cassandra

After the  installation, run

brew info cassandra

This will print out the following instructions on the screen:

To reload cassandra after an upgrade:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist

There is probably a bug in the brew recipe for OS X Mavericks, as homebrew.mxcl.cassandra.plist was not copied to the target directory for me. It stayed in the brew install source directory, ~/usr/local/Cellar/cassandra/2.0.3, so I copied it over to ~/Library/LaunchAgents/ .

Now, take a look at homebrew.mxcl.cassandra.plist. The file reads:

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “”>

<plist version=”1.0″>

















As you can see, launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist will start cassandra using the command /usr/local/opt/cassandra/bin/cassandra and it will keep it live, which means you can’t kill the process by pid.  it will just spring back to life again and again.  To stop cassandra, use the unload option.

Now, start Cassandra. But, you haven’t got a client to verify the server is working, have you?  CQL, the Cassandra Query Language client is not installed by Homebrew as part of the server install, unlike datastax distribution.

To install CQL with Homebrew,  do:

brew install python
pip install cql

now add the cqlsh script directory to your PATH.  I add mine to .bashrc:

export PATH=/usr/local/bin/:$PATH

Finally, run cqlsh

bash-3.2$ cqlsh

Connected to Test Cluster at localhost:9160.

[cqlsh 4.1.0 | Cassandra 2.0.3 | CQL spec 3.1.1 | Thrift protocol 19.38.0]

Use HELP for help.



Linux Screen Commands

Screen – keep the session window process running in back ground even when you close it. It can be listed, attached and detached on need basis.

# List all existing screen on the shh or connected box
$ screen -ls 

# connecting a screen / resume to a screen
$ screen -r <screen name>

exit and leave application open
$ Ctrl + a, d

# Creating a screen
$ screen -S <screen name>

# Killing or deleting existing screen (attached or detached)
screen -S <some_name> -X quit

I connected a linux box, started, app server , tested it and when closed my session, all processes in that session got killed automatically. QA reported that the app server has stopped working. I again connected started and moment i closed session same thing happened. Then my friend @rey told that one your session closes all process related to that session gets killed automatically, so he recommended  me to use “Screen” so that even when i exit all my process will continue. I can name the screen and can resume it later, use history and it has several other benefits.

one could log into a system remotely, start screen, work, detach from the screen session, then reattach to it at a later time, in a different location, over a different connection. This is a great way to make sure you don’t lose work if you are remotely logging in over an unreliable connection.

Giant Mountain bike Stance 1

Hi Friends,

I am excited to share the new that, today I have purchased a new mountain bike (bi cycle) worth Rs (1,30,000) One Lakh and Thirty Thousand. Its an investment towards health and fitness. Its exciting and environment friendly as well.

Enjoy this video and try it out, I am sure you will enjoy it :-)

Setting up Virtual Environment

Virtual Environment is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.

For example, you can work on a project which requires Django 1.3 while also maintaining a project which requires Django 1.0.

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
step 1:
>> sudo easy_install virtualenv

step 2:
Creating the First Virtual Environment

>> mkdir first_evn

>> virtualenv first_env/test_env
>> virtualenv first_env/test_env --no-site-packages

-no-site-packages:  If you don’t want to use any preinstalled packages from my operating system

step 3: activating environment

>> source /first_env/test_env/bin/activate

step 4: Deactivating Environment

>> deactivate

Important: if you have more than one versions of Python on your server or local system and you want to create a viertualenv for a specific version of python then please replace the step 2 with following  
For Ubuntu >> virtualenv --python=/usr/bin/python3.3 first_env/test_env For Window >> virtualenv --python=c:\Python33\python.exe first_env/test_env For mac virtualenv --python=python3.4 test_env Adding virtual env path in .base_profile file >>> pico ~/.bash_profile And add live alias ff='source ~/PATH_FROM_ROOT/VIRTUAL_ENV_NAME/bin/activate'

How to install MongoDB on Mac OS X

A guide to show you how to install MongoDB on Mac OS X.

  1. MongoDB 2.2.3
  2. Mac OS X 10.8.2

1. Download MongoDB

Get MongoDB from official website, extracts it :

$ cd ~/Download
$ tar xzf mongodb-osx-x86_64-2.2.3.tgz
$ sudo mv mongodb-osx-x86_64-2.2.3 /usr/local/mongodb

2. MongoDB Data

By default, MongoDB write/store data into the /data/db folder, you need to create this folder manually and assign proper permission.

$ sudo mkdir -p /data/db
$ whoami
$ sudo chown mkyong /data/db
Permissin is required to avoid following locking error :

Unable to create/open lock file: /data/db/mongod.lock

3. Add mongodb/bin to $PATH

Create a ~/.bash_profile file and assign /usr/local/mongodb/bin to $PATH environment variable, so that you can access Mongo’s commands easily.

$ cd ~
$ pwd
$ touch .bash_profile
$ vim .bash_profile

export MONGO_PATH=/usr/local/mongodb

##restart terminal

$ mongo -version
MongoDB shell version: 2.2.3

4. Start MongoDB

Start MongoDB with mongod and make a simple mongo connection with mongo.

Terminal 1
$ mongod
MongoDB starting : pid=34022 port=27017 dbpath=/data/db/ 64-bit host=mkyong.local
waiting for connections on port 27017
Terminal 2
$ mongo
MongoDB shell version: 2.2.3
connecting to: test
> show dbs
local	(empty)
If you don’t like the default /data/db folder, just specify an alternate path with --dbpath

$ mongod --dbpath /any-directory