nginx config 详解

nginx config 的整体布局如下

...              #全局块

events {
            #events块
   ...
}

http      #http块
{
   
    ...   #http全局块
    server        #server块
    {
    
        ...       #server全局块
        location [PATTERN]   #location块
        {
   
            ...
        }
        location [PATTERN] 
        {
   
            ...
        }
    }
    server
    {
   
      ...
    }
    ...     #http全局块
}

nginx config 配置例子

#配置用户或者组,默认为nobody nobody。
user  nginx;
#允许生成的进程数,默认为1
worker_processes  auto;

#制定日志路径,级别。这个设置可以放入全局块,http块,server块,级别以此为:debug|info|notice|warn|error|crit|alert|emerg
error_log  /var/log/nginx/error.log notice;

#指定nginx进程运行文件存放地址
pid        /var/run/nginx.pid;


events {
   
     accept_mutex on;   #设置网路连接序列化,防止惊群现象发生,默认为on
     multi_accept on;  #设置一个进程是否同时接受多个网络连接,默认为off
     #use epoll;      #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
    #最大连接数,默认为512
    worker_connections  1024;
}


http {
   
    #文件扩展名与文件类型映射表
    include       /etc/nginx/mime.types;
    #默认文件类型,默认为text/plain
    default_type  application/octet-stream;

    #给文件格式命名为main
    log_format  main  &

你可能感兴趣的:(linux,nginx,运维,服务器)