[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: need successfully installed documentation of nginx in Debian



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 21/05/2012 11:21, Joby Mathew wrote:
> Send me the detailed documentation of nginx installation and configuration process i debian if any one has

Installing nginx on Debian isn't that hard:

aptitude install nginx
or
apt-get install nginx

If you want the uwsgi modules (and others), then you can install nginx-full instead.

As for the configuration, it depends on what you want to do.
The configs below are the ones I use for development only but should provide a good start for you.
If you want several virtual hosts, you can specify them in /etc/nginx/sites-available
Then put a simlink to these files in /etc/nginx/sites-enabled to enable the sites.

Here's an example of a virtual host (a django app), every virtual host can be placed in a file of it's own
inside the sites-available directory. This config here sends the requests to a separate
server that handles the django/python stuff.

server {
    listen       80;
    server_name  calltracking;
    root /home/ict/websites/calltracking/calltracking;

    access_log /home/ict/websites/calltracking/logs/nginx_access.log;
    error_log /home/ict/websites/calltracking/logs/nginx_error.log;

    autoindex on;

    location /static/admin/ {
        autoindex on;
        root /home/ict/websites/calltracking/calltracking;
    }
    location /media/ {
        autoindex on;
        root /home/ict/websites/calltracking/calltracking;
    }
    location /static/ {
        autoindex on;
        root /home/ict/websites/calltracking/calltracking;
    }
    location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
        access_log off;
        break;
    }
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        if (!-f $request_filename) {
            proxy_pass http://calltracking_server;
            break;
        }
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|bmp|js)$ {
        expires 30d;
        break;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

A simplified version of the nginx.conf I run (private, non public facing)

user www-data www-data;
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {

    upstream calltracking_server {
        server 127.0.0.1:8001 fail_timeout=0;
    }

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format main
        '$remote_addr - $remote_user [$time_local] '
        '"$request" $status $bytes_sent '
        '"$http_referer" "$http_user_agent" '
        '"$gzip_ratio"';
    access_log	/var/log/nginx/access.log;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  2;
    tcp_nodelay        on;

    gzip  on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

The "calltracking_server" bit can be deleted from the nginx and vhost file if you aren't going to use django, so it's not
needed for a simple vhost config. In my case, that's a gunicorn instance running on port 8001.

Cheers,
Benedict
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+6MlMACgkQ6YPsX3Esu41NrgCdEe0H2ft3btwfIYwLNuj6/u+f
aC4AoNA5yWaJ5noP+XjreoqzNnh8u6mP
=CQfU
-----END PGP SIGNATURE-----


Reply to: