PHP FastCGI - connection refused

Arthur F. Bier izatop at mail.ru
Sat Apr 7 19:51:13 MSD 2007


Здравствуйте,

  Может, кто-то сможет подсказать - как избавиться от 502 ошибки,
  вызванной php-fcgi.
  В лог постоянно пишется следующее

  2007/04/07 19:28:05 [error] 18977#0: *197030 upstream prematurely
  closed connection while reading response header from upstream,
  client: 89.179.107.205, server: doomain.ru, URL:
  "/tracker.php/bbecf2b635b004b4dd85c264224e6333/scrape?info_hash=%b6t%20k8%d4%b6%e18%ea%12%e22%c2%10%bb%af%60%f0%a5",
  upstream: "fastcgi://unix:/tmp/php-fastcgi.sock:", host: "example.ru"
  И
  2007/04/07 19:29:02 [error] 18978#0: accept() failed (53: Software caused connection abort) while accepting new connection on 89.179.244.164:80

  Я уже много с чем эксперементировал. Руки начиают опускаться.
  Время от времени, на экране появляются сообщения типа:

  php-cgi in free(): warning: recursive call
  А за ними
  Fatal error: Out of memory (allocated 0) (tried to allocate 8192 bytes) in Unknown on line 0

  Еще я заметил частое возрастание активных соединений и количества
  записи на диск:

  Active connections: 293
   server accepts handled requests
   119948 119948 159343
  Reading: 12 Writing: 204 Waiting: 77

  Вот пример конфигурации:

  fastcgi_params.conf
  
fastcgi_index index.php;
fastcgi_connect_timeout 15;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

fastcgi_param   DOCUMENT_ROOT   $srv_root;
fastcgi_param   SCRIPT_FILENAME $srv_root$fastcgi_script_name;
fastcgi_param   PATH_TRANSLATED $srv_root$fastcgi_script_name;

fastcgi_param   SCRIPT_NAME     $fastcgi_script_name;
fastcgi_param   QUERY_STRING    $query_string;

fastcgi_param  REQUEST_METHOD   $request_method;
fastcgi_param  CONTENT_TYPE     $content_type;
fastcgi_param  CONTENT_LENGTH   $content_length;

# fastcgi_param   REDIRECT_STATUS 200;
fastcgi_param   SERVER_ADDR     $server_addr;
fastcgi_param   SERVER_PORT     $server_port;
fastcgi_param   SERVER_PROTOCOL $server_protocol;
fastcgi_param   SERVER_SOFTWARE "nginx";
fastcgi_param   GATEWAY_INTERFACE "CGI/1.1";
fastcgi_param   SERVER_NAME     $server_name;
fastcgi_param   REQUEST_URI     $request_uri;
fastcgi_param   REMOTE_ADDR     $remote_addr;
fastcgi_param   REMOTE_PORT     $remote_port; 
  
  nginx.conf

  user                    www;
  worker_processes        2;
  worker_priority         -20;
  worker_rlimit_nofile  10240;

  pid        /var/run/nginx.pid;

  events {
         worker_connections  4096;
         se                 kqueue;
  }
  http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format dbg '$remote_addr - $remote_user [$time_local] $request / $query_string '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile    on;
    tcp_nopush  on;
    tcp_nodelay on;
    
    client_header_timeout  30;
    client_body_timeout    60;
    send_timeout           60; 

    keepalive_timeout  15;
    
    connection_pool_size        256;
    client_header_buffer_size   1k;
    large_client_header_buffers 4 4k;
    request_pool_size           4k;
    client_max_body_size        16m; 

    postpone_output     1460;

    access_log off;
    error_log   /logs/domain.ru/error_log error;

    #gzip  on;

    server {

       set $srv_root   /www/domain.ru/htdocs/;
        
        location = /srvstat {
            stub_status on;
            access_log off;
        }
        
        location ~* ^.+\.(gz|jpg|jpeg|gif|html|css|js|png|xml)$ {
            root        $srv_root;
            expires     30d;
            access_log  off;
        }

        location /xxxadmin {
            allow 192.168.0.2;
            deny all;

            root                $srv_root;
            index               index.php;
            fastcgi_pass        unix:/tmp/php-fastcgi.sock;
            include             fastcgi_params_all;
        }

        rewrite ^/(.+)\.php/(.*)$ /$1.php?pathinfo=/$2&$query_string    last;
        
        location /pma/ {
            allow       80.68.240.0/20;
            allow       192.168.0.2;
            deny        all;
            
            index       index.php;
            root        $srv_root;
            
            fastcgi_pass        unix:/tmp/php-fastcgi.sock;
            include             fastcgi_params_all;
        }

        location / {
            rewrite "^/download.php/(.+)"       /download.php;
            root                $srv_root;
            index               index.php;
            fastcgi_pass        unix:/tmp/php-fastcgi.sock;
            include             fastcgi_params.conf;
        }
    } 
  
  spawn-php.sh и php.ini прилагаются

  Ну и, насколько помню, php иногда выпадает в кору.

  Ресурс - трекер с довольно большой посещаемостью. Сервер, насколько
  я знаю - Amd Athlon 3800+/1GB
  FreeBSD 6.2, PHP 5.2.1

-- 
С уважением,
 Arthur                          mailto:izatop at mail.ru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: php.ini
Type: application/octet-stream
Size: 47773 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20070407/511c6f92/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spawn-php.sh
Type: application/octet-stream
Size: 1416 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20070407/511c6f92/attachment-0001.obj>


More information about the nginx-ru mailing list