在我们日常搭建的网站基本都是 lnmp的架构了,通过网上一键安装包或自己编译后,刚开始运行可能还算正常,等用户量一增加,网站就会经常报502与504的错误,其实他们都和网关有关系,有相同的配置也有不同的配置502 Bad Gateway 出错就要要更改的配置就是php-fpm.cnf 里 更改 php-fpm的进程,php-fpm的进程一般有两种static和dynamic, 根据字面意思可以得出,其实一个是动态一个是静止进程,他们分别还有相应的属性要设置,可以根据http://www.linuxidc.com/Linux/2013-01/78566.htm 这里进行相应的设置504 gateway time out 这个就要多设置了一点了,首先要设置php-fpm.cnf(设置同502的配置一样),还要在设置nginx.cnf ,可以根据 http://vps.zzidc.com/changjianwenti/502.html 来进行相应的设置### 说明:下面是我的配置文件,里面的一些参数要根据服务器的配置来进行设置,请查询相关文档
nginx.cnf
user www-data; workerprocesses 4; pid /var/run/nginx.pid; events { workerconnections 40000; # multiaccept on; } http { clientmaxbodysize 20m; ## # Basic Settings ## sendfile on; tcpnopush on; tcpnodelay on; keepalivetimeout 65; typeshashmaxsize 2048; # servertokens off; # servernameshashbucketsize 64; # servernameinredirect off; servernameshashbucketsize 128; clientheaderbuffersize 32k; largeclientheaderbuffers 4 32k; include /etc/nginx/mime.types; defaulttype application/octet-stream; fastcgiconnecttimeout 300; fastcgisendtimeout 300; fastcgireadtimeout 300; fastcgibuffersize 128k; fastcgibuffers 2 256k; fastcgibusybufferssize 256k; fastcgitempfilewritesize 256k; ## # Logging Settings ## accesslog /var/log/nginx/access.log; errorlog /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzipdisable "msie6"; gzipminlength 1k; gzipbuffers 4 16k; gzipcomplevel 2; gzipvary on; # gzipvary on; # gzipproxied any; # gzipcomplevel 6; # gzipbuffers 16 8k; # gziphttpversion 1.1; # gziptypes text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; ## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ## #include /etc/nginx/naxsicore.rules; ## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passengerroot /usr; #passenger_ruby /usr/bin/ruby; ## # Virtual Host Configs ## include /etc/nginx/conf.d/.conf; include /etc/nginx/sites-enabled/; }
mail {
# See sample authentication script at:
# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# auth_http localhost/auth.php;
# pop3_capabilities "TOP" "USER";
# imap_capabilities "IMAP4rev1" "UIDPLUS";
server {
listen localhost:110;
protocol pop3;
proxy on;
}
server {
listen localhost:143;
protocol imap;
proxy on;
}
}php-fpm.cnf
pm = static pm.maxchildren = 200 pm.startservers = 5 pm.minspareservers = 5 pm.maxspareservers = 200