Nginx config

From wikinotes

Locations

${PREFIX}/etc/nginx/nginx.conf config

Validation

nginx -t                       # test all nginx configfiles
nginx -t -c /path/nginx.conf   # test a specific nginx config

Example

# /usr/local/etc/nginx/nginx.conf
user www www;
worker_processes 1;    #set to number of available cores


events {
  worker_connections 1024;
}

http {
  default_type application/octet-stream;

  server {
    server_name myserver;
    include /usr/local/etc/nginx/mime.types;
    root /usr/local/www/myserver;      # server/locations each have a root

    location / {                       # configure web location '/':    http:myserver/
      index index.html index.php;
      root /usr/local/www/myserver;    # where http:myserver/ gets it's files 
      try_files $uri $uri.html =404;
    }
  }
}