nginx

Nginx, and Common

Syntax

nginx.conf: main → events → http → server → location

Parameters

ParametersDescriptionExamplesLevel
worker_processes ( CPU ) worker_processes auto; Common
worker_connections worker_connections 1024; Common
include include /etc/nginx/conf.d/*.conf; Common
error_log and Level error_log /var/log/nginx/error.log warn; Common
access_log and access_log /var/log/nginx/access.log main; Common

Examples

worker_processes auto;

events {
    worker_connections 1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    server {
        listen 80;
        server_name example.com;
        root /var/www/html;
    }
}

nginx -t
# : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

# /etc/nginx/conf.d/mysite.conf
server {
    listen 80;
    server_name mysite.com;
    root /var/www/mysite;
}
, include

Common Errors

nginx: [emerg] unknown directive, Syntax

Tips

Related Commands