Nginx 配置文件nginx.conf 详解,nginxnginx.conf


                   Nginx 配置文件nginx.conf 详解 



vim /etc/nginx/nginx.conf


user      nginx;     #运行用户
worker_processes  4; #启动进程

error_log  /var/log/nginx/error.log;   #全局错误日志
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;         #PID文件

#工作模式及连接数上限
events {
    use   epol     #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能

    worker_connections  1024;     #单个后台worker process进程的最大并发链接数
}

 #设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
   #设定mime类型,类型由mime.type文件定义
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

     #设定日志格式
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;  #sendfile 指令指定 nginx 是否调用 sendfile 函数           (zero copy 方式)来输出文件,对于普通应用#必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,降低系统的uptime.

    #tcp_nopush     on;

     #连接超时时间
    #keepalive_timeout  0;
    keepalive_timeout  65;
     #开启gzip压缩
    #gzip  on;
     
     #设定请求缓冲
    client_header_buffer_size    1k;
    large_client_header_buffers  4 4k;


     
    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf; #分割文件

}

相关内容

    暂无相关文章