1、php-fpm 配置文件里 rlimit_files的值 要与系统的打开连接数一致 1)查看系统文件打开连接数 [root@iZ94eveq0q4Z ~]# ulimit -n 65535 2)查看一下php-fpm 配置文件里 rlimit_files的值 ; Set open file descriptor rlimit#rlimit设置打开的文件描述符 ; Default Value: system defined value rlimit_files = 65535 如果两个值不一样,则要设置为一样 方法如下: 3)设置系统打开文件连接数 [root@hotdata ~]# ulimit -HSn 65535 [root@hotdata ~]# ulimit -n 65535 [root@hotdata ~]# 设置好后重启php-fpm服务 2、 request_terminate_timeout = 0 设置为0 ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the ‘max_execution_time" ini option ; does not stop script execution for some reason. A value of "0′ means ‘off". ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_terminate_timeout = 0 因为这个参数会直接杀掉php进程,然后重启php进程,这样前端nginx就会返回104: Connection reset by peer。这个过程是很慢,总体感觉就是网站很卡 nginx可能出现502 recv() failed (104: Connection reset by peer) while reading response header from upstream 3、request_slowlog_timeout这个配置不要开启 之前服务器上开始了这个参数,并且设置如下: request_slowlog_timeout = 10导致图片处理每次都失败,每次都是502错误。 错误信息如下: Nginx的错误信息: 2015/12/28 16:20:23 [error] 649#0: *9862 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 163.177.69.13,