ngxin 配置(二),ngxin配置


1. nginx版本

[root@x nginx]# nginx -v
nginx: nginx version: nginx/1.0.9

2. nginx配置

由于我采用的是yum方式自动安装的,nginx的配置文件默认路径为:/etc/nginx/nginx.conf

  a. worker_processes

  启动的worker进行数, 通常情况下,该参数配置与主机cores数相等即可,查看cores数量的方法:

[root@iqoo1001 nginx]# grep -c 'processor' /proc/cpuinfo 
4
   所以配置 worker_processes 为4即可:

worker_processes  4;

  b. worker_cpu_affinity

  该参数实现core与具体哪一个worker绑定,可以配置如下:

worker_cpu_affinity 0001 0010 0100 1000;
  上面的配置意为每一个worker绑定一个core

  c. worker_connections 

一个worker处理的最大并发连接数,该参数配置要注意OS的nofile配置,我这里都配置的是65535

worker_connections  65535

  d. worker_rlimit_nofile 

一个worker可以打开的文件句柄数,该参数配置要注意OS的nofile配置,我这里都配置的是65535

worker_rlimit_nofile 65535;

3. 配置后的nginx.conf如下

user  nginx;
worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;

worker_rlimit_nofile 65535;

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


events {
    use  epoll;
    worker_connections  65535;
}


http {
    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;

    #aio             on;
    sendfile        on;
    #tcp_nopush      on;
    #directio        1M;

    #open_file_cache max=1000 inactive=1d;
    #open_file_cache_valid    30s;
    #open_file_cache_min_uses 2;
    #open_file_cache_errors   on;




    keepalive_timeout  15;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

推荐网站: http://wiki.nginx.org/NginxChs


相关内容

    暂无相关文章