Heim  >  Artikel  >  Backend-Entwicklung  >  Nginx+php-fpm 502 504问题 php-fpm nginx 504 java nginx php 50

Nginx+php-fpm 502 504问题 php-fpm nginx 504 java nginx php 50

WBOY
WBOYOriginal
2016-07-29 08:49:031400Durchsuche

近期自学it论坛(www.zixue.it) 常出现502,504错误

环境:

主机: 阿里云 双核CPU 2G内存
OS: centos 6.4 64位

思路:

增大nginx与php-fpm通信时的缓存文件大小与个数
静态绑定5个php-fpm进程,减少频率启动进程的开销
利用sock文件代替tcp端口通信(本地机约可提高10%的性能)
解决办法:

调整Nginx 和 php-fpm的参数如下

nginx.conf location段

<code>unix:/usr/<span>local</span>/php/<span>var</span>/run/php<span>-fpm</span><span>.</span>sock</code>

fastcgi.conf 修改内容

<code>fastcgi_buffers 32 128k;
fastcgi_buffer_size 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;</code>

php-fpm.conf

listen = /usr/local/php/var/run/php-fpm.sock

提醒:别忘给php-fpm.sock加读写权限

<code>pm = <span>static</span><span># 静态绑定5个进程</span>
pm.max_children = <span>5</span></code>

效果:

论坛首页速度快了约30毫秒,且经过2周的临床观察,未再发生502 ,504错误

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了Nginx+php-fpm 502 504问题,包括了nginx,504方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn