免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 13107 | 回复: 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.     }
复制代码

论坛徽章:
2
狮子座
日期:2013-08-26 15:25:32金牛座
日期:2013-09-05 15:45:36
2 [报告]
发表于 2009-08-27 14:19 |只看该作者
现在最新的spawn-fcgi已经不需要自己添加启动脚本了
具体参数可以去/usr/local/etc/rc.d/spawn-fcgi中看看
有个spawn_fcgi_max_requests=""
默认好像是1000
自己修改吧

论坛徽章:
0
3 [报告]
发表于 2009-08-27 14:32 |只看该作者
原帖由 kisswen 于 2009-8-27 14:19 发表
现在最新的spawn-fcgi已经不需要自己添加启动脚本了
具体参数可以去/usr/local/etc/rc.d/spawn-fcgi中看看
有个spawn_fcgi_max_requests=""
默认好像是1000
自己修改吧


谢谢您的答复!

是不是在 #ee /etc/rc.conf
里面添加:

spawn-fcgi_enable="YES"

论坛徽章:
0
4 [报告]
发表于 2009-08-27 15:06 |只看该作者
原帖由 kisswen 于 2009-8-27 14:19 发表
现在最新的spawn-fcgi已经不需要自己添加启动脚本了
具体参数可以去/usr/local/etc/rc.d/spawn-fcgi中看看
有个spawn_fcgi_max_requests=""
默认好像是1000
自己修改吧

http://bbs3.chinaunix.net/thread-1529473-1-2.html

论坛徽章:
0
5 [报告]
发表于 2009-08-27 15:18 |只看该作者
原帖由 scyzxp 于 2009-8-27 15:06 发表

http://bbs3.chinaunix.net/thread-1529473-1-2.html


谢谢!

你这片文章,我之前就看过了,也照做了,还是一样~~~

头大啊.

论坛徽章:
2
狮子座
日期:2013-08-26 15:25:32金牛座
日期:2013-09-05 15:45:36
6 [报告]
发表于 2009-08-27 15:54 |只看该作者
没环境测试
不过我用ab测试的时候模拟1000个客户端刷的时候都没错误啊
而且我机子配置还挺撮的~

论坛徽章:
0
7 [报告]
发表于 2009-08-27 23:00 |只看该作者
原帖由 hac_bb 于 2009-8-27 15:18 发表


谢谢!

你这片文章,我之前就看过了,也照做了,还是一样~~~

头大啊.


还有一个办法可以解决。。。

http://www.thismail.org/bbs/thread-3412-1-1.html

论坛徽章:
0
8 [报告]
发表于 2009-08-28 15:34 |只看该作者
# deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }

这个是什么意思的?

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
9 [报告]
发表于 2009-08-28 15:44 |只看该作者
.htaccess 上面不是写拒绝访问 .ht文件的

论坛徽章:
0
10 [报告]
发表于 2009-08-30 22:12 |只看该作者
原帖由 kisswen 于 2009-8-27 14:19 发表
现在最新的spawn-fcgi已经不需要自己添加启动脚本了
具体参数可以去/usr/local/etc/rc.d/spawn-fcgi中看看
有个spawn_fcgi_max_requests=""
默认好像是1000
自己修改吧



ports 里面没有
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP