STEP1

Install Nginx and php5 packages;

sudo apt-get install nginx-full

sudo apt-get install php5-apcu php5-fpm php5-curl php5-cli php5-tidy php5-sqlite

STEP2

Configure nginx.conf file with the following example;
nginx.conf file - https://gist.github.com/altan-me/e184f8af116da94be264

Quick one-line Install nginx.conf file replacing the default;

sudo wget -O /etc/nginx/nginx.conf https://gist.githubusercontent.com/altan-me/e184f8af116da94be264/raw/1369aca3bc197eb4f62f03fa68e5c059affd4f50/nginx.conf


Example config;

user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_priority 15; 
worker_rlimit_nofile 1024;

events {
        worker_connections 512;
        multi_accept on;
        accept_mutex_delay 500ms; 
        use epoll;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        server_tokens off;

        # Log Errors
        error_log /var/log/nginx/error.log;

        # Timeouts, do not keep connections open longer then necessary to reduce
        # resource usage and deny Slowloris type attacks.
        keepalive_timeout 20;
        client_header_timeout 20;
        client_body_timeout 20;
        reset_timedout_connection on;
        send_timeout 20;

        #Limit for Fail2ban
        #limit_req_zone  $binary_remote_addr  zone=app:10m   rate=2r/s;

        # Max Allowed Connections per IP
        limit_conn_zone $binary_remote_addr zone=addr:5m;
        limit_conn addr 100;

        include /etc/nginx/mime.types;
        default_type text/html;
        charset UTF-8;

        # Gzip Settings
        gzip on;
        gzip_proxied any;
        gzip_min_length 256;
        gzip_comp_level 6;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        # Cache informations about file descriptors, frequently accessed files
        open_file_cache max=100000 inactive=20s;
        open_file_cache_valid 30s;
        open_file_cache_min_uses 2;
        open_file_cache_errors on;

        # Virtual Host Configs
        include /etc/nginx/sites-enabled/*;
}

STEP3

Remove example/default pre-installed Virtual-host file;

sudo rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default

Create new Virtual-host file;
Run the following command replacing YOURDOMAINNAME eg. altan.me

sudo nano /etc/nginx/sites-available/YOURDOMAINNAME

EXAMPLE Virtual host Files;

When editing the virtual-hosts file be sure to edit in sites-available;
The following command soft links the sites-available and sites-enabled locations;

sudo ln -s /etc/nginx/sites-available/YOURDOMAINNAME /etc/nginx/sites-enabled/YOURDOMAINNAME

    (Soft links: original >> link)
    (this is an important step)

STEP4

Configure php;

Using nano edit the following line in php.ini;

sudo nano /etc/php5/fpm/php.ini

    cgi.fix_pathinfo=1
Change to:
    cgi.fix_pathinfo=0

Using nano edit the following line in www.conf;

sudo nano /etc/php5/fpm/pool.d/www.conf

    ;listen = /var/run/php5-fpm.sock
Change to:
    listen = 127.0.0.1:9000

Restart php to enable changes;

sudo service php5-fpm restart

STEP5

Creating default web directory;

sudo mkdir /var/www
sudo mkdir /var/www/YOURDOMAIN

Run configtest;

sudo service nginx configtest

All config modifications only take effect after restarting nginx or running the reload command;

sudo service nginx restart

or

sudo service nginx reload