Installing high-performance Nginx for first time

I have been somewhat lazy nowadays (hey it’s a summer!), but I thought I need to post a quick guide about installing high performance Nginx daemon. It’s a super fast web serving daemon that is the best choice for static content serving at very high speeds. It requires small hardware resources and places very small load on the hardware.

Download the latest stable version 0.7.61 or fetch a newer version from

Installing nginx:
(depending on the required modules, I prefer to disable all modules that are not needed, for example if you do not wish to host SSL pages, don’t enable SSL and so on).

tar zxvf nginx-0.7.61.tar.gz
cd nginx-0.7.61

(you can also specify –prefix value if you wish to install nginx in a different folder)

Now you will need to configure nginx.conf file before firing up Nginx daemon.

For better security run Nginx under a non-privileged user:

user nobody;

For medium to high load sites I suggest increasing worker_processes to 5 to 15, or even more if your hardware allows it.

worker_processes 10;

To increase max allowed clients that can access your site increase worker_connections. A good value for start is 256 and higher if you have a more powerful hardware.

events {
worker_connections 512;

Please note! If you run a Nginx in reverse proxy configuration you will need to divide this value by 4 because two connections will be opened to client and two to the back-end. If you have worker_processes set to 10 and worker_connections set to 256, then max clients that can access your site will be worker_processes * worker_connections / 2, thus 10 * 512 / 2 becomes 2560 connections.

Now in http {} section you will need to define some settings like mime.types, default_type, log_format, access_log, sendfile, tcp_nopush, keepalive_timeout. That’s pretty self explaining. Just a quick note: Nginx requires very low hardware requirements for keeping keepalive connections active and it’s well know to take less than 30Mb of RAM for 10000 active keepalive connections. Make sure you have correctly calculated max client settings using the formulas above.

Now comes the server {} section were you define Listen to address, ports and custom settings, like redirects etc.


server {
server_name  localhost;

access_log  logs/host.access.log  main;

location / {
root   html;
index  index.html index.htm;

error_page  404              /404.html;

error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
} IP is just an example, you will need to specify your allocated server IP.

I hope this quick guide helped you out a little. We will soon publish more in-depth guide about configuring Nginx.


  1. raghu veer says:

    how much ram for above calculated 2560 active connections?

    what is estimated server spec required? thank you

  2. Kai says:

    The server we tested this on was with 8GB of RAM :)

Leave a Reply