免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 13122 | 回复: 25
打印 上一主题 下一主题

[FreeBSD] freebsd+nginx 经常502 Bad Gateway~ [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-27 13:25 |只看该作者 |正序浏览
请教一下:
我freebsd7.2+nginx/0.7.58+spawn-fcgi v1.6.2+php5.2.9
经常会502是怎么回事呀?~ 服务器负载很小,有时候一天,有时候几个小时就出现大量502,重启服务都没效果,只有重启系统才会好~
以前用nginx.05.xx+lighttpd(php-cgi)+php5.2.9 也是经常502,所以后来才升级,升完还是经常502,网上查看了,基本上都是转载张天师的,按上面设置的更改,还是经常502,快崩溃了...  帮忙指点一下,谢谢~

spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 25 -f /usr/local/bin/php-cgi
php-cgi  开25个,开50个,基本上也是那样,一段时间后就502~~~  崩溃啊!!!

部分nginx.conf



  1. user  www;
  2. worker_processes  1;

  3. #error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;

  6. #pid        logs/nginx.pid;


  7. events {
  8.     worker_connections  51200;
  9. }


  10. http {
  11.     include       mime.types;
  12.     default_type  application/octet-stream;

  13.     log_format  main  '$remote_addr - $remote_user [$time_local] $request '
  14.                       '"$status" $body_bytes_sent "$http_referer" '
  15.                       '"$http_user_agent" "$http_x_forwarded_for"';

  16.     access_log  off;

  17.     server_names_hash_bucket_size 128;
  18.     client_header_buffer_size 32k;
  19.     large_client_header_buffers 4 32k;
  20.        
  21.     sendfile        on;
  22.     tcp_nopush     on;

  23.     #keepalive_timeout  0;
  24.     keepalive_timeout  60;

  25.     tcp_nodelay on;

  26.     fastcgi_connect_timeout 300;
  27.     fastcgi_send_timeout 300;
  28.     fastcgi_read_timeout 300;
  29.     fastcgi_buffer_size 64k;
  30.     fastcgi_buffers 4 64k;
  31.     fastcgi_busy_buffers_size 128k;
  32.     fastcgi_temp_file_write_size 128k;

  33.     gzip on;
  34.     gzip_min_length  1k;
  35.     gzip_buffers     4 16k;
  36.     gzip_http_version 1.0;
  37.     gzip_comp_level 2;
  38.     gzip_types       text/plain application/x-javascript text/css application/xml;
  39.     gzip_vary on;

  40.     server {
  41.         listen       80;
  42.         server_name  null;

  43.         #charset koi8-r;

  44.         #access_log  logs/host.access.log  main;

  45.         location / {
  46.             root   /dev/null;
  47.             index  index.html index.htm;
  48.         }

  49.         #error_page  404              /404.html;

  50.         # redirect server error pages to the static page /50x.html
  51.         #
  52.         error_page   500 502 503 504  /50x.html;
  53.         location = /50x.html {
  54.             root   /usr/local/www/nginx-dist;
  55.         }

  56.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  57.         #
  58.         #location ~ \.php$ {
  59.         #    proxy_pass   [url]http://127.0.0.1[/url];
  60.         #}

  61.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  62.         #
  63.         location ~ \.php$ {
  64.             root           html;
  65.             fastcgi_pass   127.0.0.1:9000;
  66.             fastcgi_index  index.php;
  67.             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  68.             include        fastcgi_params;
  69.         }

  70.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  71.         {
  72.           expires      15d;
  73.         }

  74.         location ~ .*\.(js|css)?$
  75.         {
  76.           expires      1d;
  77.         }   


  78.         if (-d $request_filename){
  79.                 rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
  80.         }

  81.         # deny access to .htaccess files, if Apache's document root
  82.         # concurs with nginx's one
  83.         #
  84.         location ~ /\.ht {
  85.             deny  all;
  86.         }
  87.     }
复制代码

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
26 [报告]
发表于 2009-09-18 17:45 |只看该作者
好像是这个参数:

worker_rlimit_nofile   

把它设置得和系统的打开文件数一致试试,但是我感觉对于繁忙的站点,文件数很容易超过上限,基本上没法解决。

论坛徽章:
0
25 [报告]
发表于 2009-09-18 14:50 |只看该作者
原帖由 zhengwei_zw 于 2009-9-18 10:10 发表
upstream backend {
server 127.0.0.1:9000;
server 127.0.0.1:9001;
}

这种方式怎么样?


我觉得502有时候是php执行超时



都是些临时的措施,期待官方提供新的解决方案。

论坛徽章:
0
24 [报告]
发表于 2009-09-18 10:10 |只看该作者
  1. upstream backend {
  2. server 127.0.0.1:9000;
  3. server 127.0.0.1:9001;
  4. }
复制代码


这种方式怎么样?


我觉得502有时候是php执行超时

论坛徽章:
0
23 [报告]
发表于 2009-09-17 10:50 |只看该作者
原帖由 lsstarboy 于 2009-9-16 09:32 发表
据说有个文件限制,好像是什么rlimit字样,很容易造成这个毛病,修改一下试试吧。
还有系统本身的文件数限制。



能否具体说说?

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
22 [报告]
发表于 2009-09-16 09:32 |只看该作者
据说有个文件限制,好像是什么rlimit字样,很容易造成这个毛病,修改一下试试吧。
还有系统本身的文件数限制。

论坛徽章:
0
21 [报告]
发表于 2009-09-15 23:33 |只看该作者
原帖由 HonestQiao 于 2009-9-12 19:31 发表
request_terminate_timeout 设置为0s秒看看效果如何


好像不可以的。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
20 [报告]
发表于 2009-09-12 19:31 |只看该作者
request_terminate_timeout 设置为0s秒看看效果如何

论坛徽章:
0
19 [报告]
发表于 2009-09-12 16:11 |只看该作者
LS,人总是贪心的

论坛徽章:
0
18 [报告]
发表于 2009-09-12 01:21 |只看该作者
过于贪心结果
把你的很多参数设设小一点
人不能过于贪心
你以为你的机器是大型计算机哪
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP