日期:2014-05-16  浏览次数:20574 次

lnmp之php-fpm+nginx+ulimit的综合设置之故障排除

相信其它的地方大家都懂,这里重点说下面粗体注释标注部分 参数设置必须与系统的 ulimit -Sn 参数一致,并且 php-fpm.conf,nginx,conf中的设置要一致,否则会出现诸多历史遗留问题以及不和谐的ERROR WRING问题
以下是nginx.conf里的一些 配置信息,重点说红色部分
#user  nobody;
user www www;
worker_processes  auto;
#add by Happy; set the value == system's ulimit -sn 's value


#############################################
worker_rlimit_nofile  65535;
############################################
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
pid        logs/nginx.pid;
events {
    # set by Happy; set the value == system's "ulimit -sn" is value
    # if use is epoll,the worker_connections 65535+1  but sys's ulimit -sn == 65536
############################################
    worker_connections  65535;
############################################
    multi_accept  on;
    use  epoll;
}




http {
    include       mime.types;
    default_type  application/octet-stream;
    # add by Happy 2014-04-18
    server_names_hash_bucket_size  128;
    client_header_buffer_size      32K;
    large_client_header_buffers    4 32k;
    # set user upload size
    client_max_body_size           8m;
    # add end 


    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  logs/access.log main;


    #display nginx version add this,
    #but you have set fastcgi.conf set 
    #fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
    #fastcgi_param SERVER_SOFTWARE nginx;
    #this is by Happy set for 2014-04-19
    server_tokens off;


    sendfile       on;
    #tcp_nopush     on;
    tcp_nopush   on;
    tcp_nodelay    on;
    #add by Happy 2014-04-19
    fastcgi_connect_timeout    300;
    fastcgi_send_timeout       300;
    fastcgi_read_timeout       300;
    fastcgi_buffer_size        64k;
    fastcgi_buffers         4  64k;
    fastcgi_busy_buffers_size  128k;
    fastcgi_temp_file_write_size  128k;
    #keepalive_timeout  0;
    keepalive_timeout  60;
    client_header_timeout  10;
    client_body_timeout  10;
    #reset_timeout_connection  on;
    send_timeout  10;
    #set one ip link num and memory
    limit_conn_zone $binary_remote_addr zone=addr:5m;
    limit_conn addr 100;
    #open gzip by Happy
    gzip  on;
    gzip_disable      "msie6";
    gzip_proxied