大漠驼铃

置身浩瀚的沙漠,方向最为重要,希望此blog能向大漠驼铃一样,给我方向和指引。
Java,Php,Shell,Python,服务器运维,大数据,SEO, 网站开发、运维,云服务技术支持,IM服务供应商, FreeSwitch搭建,技术支持等. 技术讨论QQ群:428622099
随笔 - 238, 文章 - 3, 评论 - 117, 引用 - 0
数据加载中……

Nginx简单配置

#运行Nginx的用户
user  nginx;
#Nginx运行的进程数,拥有几个逻辑CPU,就设置为几个worker_processes 为宜,但是 worker_processes 超过8个就没有多大意义了
worker_processes  8;

#制定进程到cpu(四cpu:0001 0010 0100 1000)
worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000;

#worker_rlimit_nofile配置要和系统的单进程打开文件数一致。
worker_rlimit_nofile 100000;

#错误日志,在出现错的时候可以tail查看,查找具体的错误
error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

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


events {
     #使用epoll(linux2.6的高性能方式)
    use epoll;
    #每个进程最大连接数(最大连接=连接数x进程数)
    worker_connections  10240;
}


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    
    access_log  /var/log/nginx/access.log  main;

    #tcp and gzip相关配置
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    gzip            on;
    gzip_static     on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    #默认编码
    charset UTF-8;


    #嵌套upstream.conf
    include upstream.conf;
    
    #长链接超时时间
    keepalive_timeout  65;
    limit_conn_zone   $binary_remote_addr  zone=addr:10m;

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

   
}

posted on 2013-10-11 14:41 草原上的骆驼 阅读(235) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: