[文章作者:张宴 本文版本:v1.0 最后修改:2008.07.30 转载请注明原文链接:http://blog.zyan.cc/read.php/361/]

  昨日,有朋友问我,他将Web服务器换成Nginx 0.6.31  + PHP 4.4.7(FastCGI)后,有时候访问会出现“502 Bad Gateway”错误,如何解决。

  我让按照以下两个步骤去解决,最后在第2步中将FastCGI的timeout时间增加为300,问题解决:

  PS:比较羡慕迅雷的Web服务器,16G内存。



  1、查看当前的PHP FastCGI进程数是否够用:
netstat -anpo | grep "php-cgi" | wc -l

  如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。



  2、部分PHP程序的执行时间超过了Nginx的等待时间,可以适当增加nginx.conf配置文件中FastCGI的timeout时间,例如:
......
http
{
......
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
......
}
......



Tags: , , , ,



技术大类 » Web服务器 | 评论(120) | 引用(0) | 阅读(221269)
ta
2009-2-8 23:49
我的是 nginx/0.6.31 應該點做... 多謝...
hid
2009-2-16 10:40
引用
 如果实际使用的“FastCGI进程数”接近预设的“FastCGI进程数”,那么,说明“FastCGI进程数”不够用,需要增大。

这个在哪加大呢?
mk2 Email Homepage
2009-4-22 09:53
smoke访问量太大的话,似乎怎样设置,都话出现bad gateway错误的。。。
Max.L Email
2009-5-11 01:23
似乎php模块丢失,wget也会出现502错误,reload一下可以解决?
dh20156 Homepage
2009-5-12 18:34
貌似按照楼主给出的步骤全做完就会出现502,之前只做了php-fpm和nginx反而可以。
dh20156
2009-5-13 14:02
成功架设Nginx+Php Web服务器之后的一个总结,成功设置Nginx开启多域名多站点,并且不会出现502 Bad Gateway错误!
http://www.w3cgroup.com/article.asp?id=250
hmfsmile
2009-6-10 13:24
接近预设的“FastCGI进程数”这个在那里查看。
如何知道预设的是多少
小鹏
2010-5-17 18:29
宴哥,我最近使用你的nginx+php文档,来跑我的php论坛,首页是在测试,环境是VM和rhel5.4
   但是自从第一次安装好后,后来重新编译就不行,很多时候都是php不能正常显示,测试页也不能打开,
502 bad gateway这个提示。。。
胡军 Email
2010-8-21 00:24
嘿嘿  我也发现这样的问题了  结果是nginx的日志文件太大   现在已经好了     每天定时替换日志文件,    不过还在想有其他的方式没。    不晓得我是特例还是日志文件大了也会导致502   如果张老师验证会导致还希望加上,
Duron Email Homepage
2010-9-18 17:00
依然不行,下面是通过分析日志得出的出错最小时间段内的错误日志2010/09/18 05:43:47 [info] 29174#0: *44016 client 99.18.90.88 closed keepalive connection2010/09/18 05:43:50 [info] 29172#0: *44108 client 61.64.173.132 closed keepalive connection2010/09/18 05:43:51 [info] 29172#0: *44115 client 61.64.173.132 closed keepalive connection2010/09/18 05:43:52 [info] 29174#0: *43779 client 72.91.76.178 closed keepalive connection (104: Connection reset by peer)2010/09/18 05:43:56 [info] 29174#0: *43886 client 60.165.183.187 closed keepalive connection (104: Connection reset by peer)2010/09/18 05:44:02 [info] 29172#0: *44129 client 61.64.173.132 closed keepalive connection2010/09/18 05:44:03 [info] 29172#0: *44130 client 61.64.173.132 closed keepalive connection2010/09/18 05:44:05 [info] 29172#0: *44113 client closed prematurely connection, so upstream connection is closed too (104: Connection reset by peer) while sending request to upstream, client: 66.63.164.2, server: www.socialbookmarkworld.com, request: "GET /newuser.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "domain.com"
一颗白菜
2011-3-7 10:32
张老师,您好.我现在正在学习LINUX系统.这2天装NGINX,发现NGINX不能访问PHP,报错,502 Bad GateWay.我看了你的文章,但是还是没解决出来.如果可以的话,我希望张宴老师加下我QQ,指点我下.万分感激.谢谢,我的QQ:303751078
yirihan
2011-3-13 22:10
PHP-CGI经常会卡几分钟,流量从几十M掉到几十K,网站很卡,一会又好了...... 我完全按照张总的教程来的而且整个编译过程没有出现错误提示。我是 centos环境
holmes
2011-6-22 17:09
我的网站 ps -aux| grep 'php-cgi'|wc -l  是99
而netstat -anpo|grep 'php-cgi'|wc -l 怎么一直的5

有点疑惑,望解答,谢谢
gp02jm46 Email Homepage
2011-6-23 01:03
皇冠娱乐投注公司坚持“公平公正公开”以诚待客,信誉第一的原则,为客户提供一流的服务,最快捷的付款、提款服务。无论您身在何处,只要有一张银联的银行卡,就可以通过网络实时存款、取款,安全、快捷、方便。且使用最新的加密和保护技术, 保证您财务信息的绝对安全。网址:http://www.y4399.com
jzswjy2005 Email
2011-8-9 15:50
我在开启PHP——FPM时报这个错:
Starting php_fpm Error in argument 1, char 1: no argument for optio           n -
Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php-cgi <file> [args...]
  -a               Run interactively
  -C               Do not chdir to the script's directory
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profi           ler
  -f <file>        Parse <file>.  Implies `-q'
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -q               Quiet-mode.  Suppress HTTP Header output.
  -s               Display colour syntax highlighted source.
  -v               Version number
  -w               Display source with stripped comments and whites           pace.
  -z <file>        Load Zend extension <file>.
................................... failed
louis vuitton uk Email Homepage
2011-11-23 09:03
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
十窝羊
2011-11-23 11:37
张老师 nginx出现502错误 ,php-fpm.log里出现报错:[NOTICE] fpm_got_signal(), line 48: received SIGCHLD [WARNING] fpm_children_bury(), line 215: child 11878 (pool default) exited on signal 15 SIGTERM after 237.287131 seconds from start [NOTICE] fpm_children_make(), line 352: child 12422 (pool default) started [ERROR] fpm_stdio_prepare_pipes(), line 197: pipe() failed: Too many open files (24) [NOTICE] fpm_got_signal(), line 48: received SIGCHLD [WARNING] fpm_children_bury(), line 215: child 11879 (pool default) exited on signal 15 SIGTERM after 237.157199 se [NOTICE] fpm_children_make(), line 352: child 12423 (pool default) started [ERROR] fpm_stdio_prepare_pipes(), line 197: pipe() failed: Too many open files (24) [WARNING] fpm_request_check_timed_out(), line 158: child 11880, script '/founder/wwwroot/bbs/home.php' (pool default) execution timed out (5.085873 sec), terminating我的ulimit已经增加了# vi /etc/sysctl.conf 底部添加fs.file-max=65535 #vi /etc/security/limits.conf加上* soft nofile 65535* hard nofile 65535
aophgv5osf Email Homepage
2011-11-23 22:48
654884 2007年12月08日04:52 Reading (loading. ..) Comments (1 ) Category : Ψалт ,moncler store
Post cancel


| Back to logs list





| Back to logs list
the other:

  
   timberland shoes for sale Copyright
  
   tory burch leopard Summary
  
   moncler usa
saiecrie Email Homepage
2011-11-23 23:42
☞ I only provide support to people links, the problems occasioned by the auxiliary do I explain, thank you,uggs for cheap! ,cheap uggs for sale! ,uggs for sale!

☞ manifold auxiliary:

� � � � � � � � � � � � � legendary PW � � � � �

PK tiny assistant timely

Bingtian accelerator

� � � � � � � assistant game hall � � � � � � � � � � �

dumplings QQ Landlords note card device

QQ note card each day

tour Seba note card device

Penguin QQ note card device

I adore the note card device

Friends of the Friends of the memorandum card device

Invincible note card device

naivete surround note card device

QQ games, the guanidine

class QQ games lobby to open Lianliankan registrar

Mirror &#65279;

� � � � � � � � � QQ Dancer � � � � � � � � �

dance of myth

's assistant

simple Dancer

quite evil from the auxiliary wing

lonely

Dancer a sky god

assistant

Dancer beef

Dancer ABC

memories dance

Dancer slightly

Dancer Dancer disposition

Yi Bao

Dancer AA

Hyun Hyun sound

easy to dance

Perfect Community

Dancer Dancer Rainbow

small dream

memory assistant

Dancer dream hanging (Leveling with G)

Dancer Dream Dancer hanging &#65279;

Union above benefit of the brush tool

sun

Dancer Dancer main

good Happy ( the old version)

nice Happy (new version)

Dancer hidden off

leaves Assistant

china Concert auxiliary

Hyun Dance child dance Hyun Hyun

purple

brother

Dancer Dancer Dancer conscience sound

storm

Dancer Dream Charm

Happy Dancer Dancer

Reds

perfect hasty (Speed ​​auxiliary do a)

Grand Trace Assistant - (do DNF patch)

peak

Dancer family

son Auxiliary (Auxiliary Speed ​​do a)

Kung Fu Panda

perfect rhythm

sister plug-in (three of the nightmare)

absolute flying (has stopped updating)



Tanabata dance dance melody

Flurry assistant

My Love Dancer

memories dance

Dancer family

Colorful

HE HE auxiliary

Dancer Eva

Dancer Binbin

ET answer

answer device

Want a dog
xiaoman5202 Email Homepage
2011-11-24 05:52
comment s’abonner,ugg sales
faites passer la souris sur chaque segment pour vous abonner avec ou des fils .
yahoo! newspaper intend des dizaines de fils rss que vous pouvez lire dans mon yahoo,occhiali da sole carrera! ou avec un agrégateur de fils tiers. cliquez ici gush en savoir and sur rss et son utilisation avec yahoo,lunettes vue chanel! actualités.
分页: 2/6 第一页 上页 1 2 3 4 5 6 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]