How to start with Nginx

Nginx logoBefore you start reading this, I would like to warn you about that I am not going to give to very technical background. I only want to talk about my humble experience with nginx.

A month ago, my boss asked me to learn nginx which I had no clue what it was. Actually he told me “You gotta better learn this as soon as possible. I super do not care how you do it and I am not going to baby sit for you or hold your hand. Because a real programmer have to learn this shit. If you can not you should better quit while you have a chance”. Yes that was the exact sentence. Of course I was desperate and freaked out, started studying immediately.

Let me clear this point. Although I am a programmer I do not have too much knowledge. I can even classified myself a useless computer nerd. You know, I really can not spend whole my free time front of the computer in order to catch up with every update or latest news. I would rather prefer to go to beach and surf(yes I do surf in a pathetic level), go to a bike riding or hiking.

For the people who does not heard nginx before you can go the their site and check. It is basically an open source HTTP server. It is developed by some russian I think and it started to be preferred over apache and it is getting more and more popular. The biggest advantage of Nginx is being way faster then apache. Below you will see a graph of respond time Nginx vs Apache. As you can see there is anonymous amount of difference between these two.  I took the graph from Mondo tech web site. If you would like to read more technical details you can also go there and check it out.

nginx chart respond time vs apache

Before you are starting to nginx, you have to make sure you actually have fundamental skills for UNIX and terminal. This might sound bit stupid for the people who is already familiar with server side but if you never involved with them before whole in your life like me, it is a very big tip. Next step that I had follow if installing Nginx on my Mac(yes I use mac and love it). I do not know whether it is the best approach but I install nginx with Macports.

http://mjijackson.com/2009/07/install-nginx-on-osx

In this site it gives clear and simple instructions about how to instal Nginx and macport on your computer. Once you see follow every step you supposed to see “welcome to Nginx” on your localhost. Great you have finished the first step. Now you have to know 3 location(they are the most important ones)

  1. /opt/local/share/nginx/html/  This location is where your pages are stored. You can add pages and play around with them
  2. /opt/local/etc/nginx/nginx.cof  This is your configuration file, where you can change roots, redirect the pages, play with 404 files..etc. But you have to remember that whenever you make a change in this file you actually have to restart nginx with a code(I will give it below)
  3. /opt/local/var/log/nginx/access.log or error log  This are the files where you can see the outputs or errors and access. They are really handy especially when you are playing with nginx.conf file

If you want to restart the nginx which you will use a lot of times. You want to use the following command in Terminal

sudo kill -HUP `cat /opt/local/var/run/nginx/nginx.pid`

If you would like to access your error log or access log simply type one of the following codes in terminal

 cat /opt/local/var/log/nginx/access.log

 cat /opt/local/var/log/nginx/access.log

Nginx also has good wiki page, if you want to learn more and have a further look.

Hope it helps a little bit. Please let me know if you have any questions, I will try to help as much as I can.

Keep it good

Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s