Nignx - ilo

Konfiguracja serwerów, usług, itp.
kozikowski11
Posty: 6
Rejestracja: 02 lutego 2011, 00:23

Nignx - ilość połączeń i spawn-fastcgi

Post autor: kozikowski11 »

Witam.
Próbuję już cały dzień skonfigurować serwer oparty na Nginx, mysql i spawn-fastcgi. Wszystko ładnie działa gdyby nie fakt, że kiedy trwa jedno połączenie, to serwer nie odpowie na inne póki tamtego nie zakończy. Serwer powinien dać radę na 400 otwartych połączeniach, na których będzie strumień pliku, w tej chwili jedno połączenie i koniec. Myślę że to wina konfigu, dlatego załączam wszystko co mam. Liczę na Waszą pomoc, bo już włosy z głowy rwę.

Pozdrawiam
kozikowski11

nginx.conf

Kod: Zaznacz cały

user www-data;
worker_processes  4;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    access_log    /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  0;
    #keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
/etc/init.d/php-cgi

Kod: Zaznacz cały

#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-cgi
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: spawns the php-cgi
# Description:       spawns the php-cgi
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=php-cgi
DESC=php-cgi

test -x $DAEMON || exit 0

PIDFILE="/var/run/$NAME.pid"
DAEMON="/usr/bin/php-cgi"
SPAWN_FCGI="/usr/bin/spawn-fcgi"
FCGI_PORT=9000
FCGI_USER="www-data"
FCGI_GROUP="www-data"
FCGI_CHILDREN=0

# Include php-cgi defaults if available
if [ -f /etc/default/php-cgi ] ; then
        . /etc/default/php-cgi
fi

SPAWN_FCGI_OPTS="-f $DAEMON -a 127.0.0.1 -p $FCGI_PORT -u $FCGI_USER -g $FCGI_GROUP -C $FCGI_CHILDREN -P $PIDFILE"

set -e

. /lib/lsb/init-functions

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
        echo "$NAME."
        ;;
  restart)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec "$DAEMON" || true
        sleep 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$SPAWN_FCGI" -- $SPAWN_FCGI_OPTS || true
        echo "$NAME."
        ;;
  status)
        status_of_proc -p $PIDFILE "$DAEMON" php-cgi && exit 0 || exit $?
        ;;
  *)
        echo "Usage: $NAME {start|stop|restart|status}" >&2
        exit 1
        ;;
esac

exit 0
/etc/nginx/sites-available/default

Kod: Zaznacz cały

server {
  listen 80;
  server_name localhost;
  root /var/www/default;
  access_log /var/log/nginx/$host.access.log;
  error_log /var/log/nginx/error.log error;

  location / {
    root   /var/www/default/;
    index  index.php;

    # serve static files directly
    if (-f $request_filename) {
      access_log        off;
      expires           30d;
      break;
    }

    rewrite ^(.*) /index.php last;
  }

  location ~ \.php {
    fastcgi_index  index.php;

    set  $script     $uri;
    set  $path_info  "";
    if ($uri ~ "^(.+\.php)(/.*)") {
      set  $script     $1;
      set  $path_info  $2;
    }
    fastcgi_pass   127.0.0.1:9000;
    include /etc/nginx/fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  /var/www/default$script;
    fastcgi_param  PATH_INFO        $path_info;
    fastcgi_param  SCRIPT_NAME $script;
  }

  location ~ /\.ht {
    deny  all;
  }
}

/etc/nginx/fastcgi_params

Kod: Zaznacz cały

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  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

      fastcgi_connect_timeout 60;
      fastcgi_send_timeout 180;
      fastcgi_read_timeout 180;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 4 256k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_temp_file_write_size 256k;
      fastcgi_intercept_errors on; 

Awatar użytkownika
redelek
Posty: 89
Rejestracja: 19 marca 2007, 13:45

Post autor: redelek »

Wygląda na dobrze zrobionego, a sprawdź, czy w logach serwera lub systemowych nic Ci nie wywala? Ja miałem taki problem bo jądro nie potrafiło otwierać tylu plików ile serwer www dostawał zapytań. Sprawdź logi.
kozikowski11
Posty: 6
Rejestracja: 02 lutego 2011, 00:23

Post autor: kozikowski11 »

A no faktycznie, "kilka" bledow mi zwraca..

Kod: Zaznacz cały

2011/02/02 13:49:22 [error] 5334#0: *2506 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:49:40 [error] 5334#0: *2508 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:49:53 [error] 5334#0: *2510 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:49:56 [error] 5334#0: *2512 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:50:25 [error] 5334#0: *2514 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:50:31 [error] 5334#0: *2516 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:50:32 [error] 5336#0: *2518 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:50:35 [error] 5336#0: *2520 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:51:17 [error] 5336#0: *2522 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:51:27 [error] 5336#0: *2524 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:51:44 [error] 5336#0: *2526 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:51:47 [error] 5336#0: *2528 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:51:51 [error] 5336#0: *2530 connect() failed (111:  Connection refused) while connecting to upstream, client:  217.144.201.54, server: localhost, request: "GET  /watch.php?q=9aa3aee12c913a5934dcd116df3bb940&file=2D1BTVNP&pos=0  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:52:08 [error] 5336#0: *2532 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.216.202, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"
2011/02/02 13:52:15 [error] 5336#0: *2534 connect() failed (111:  Connection refused) while connecting to upstream, client:  188.165.213.73, server: localhost, request: "GET /slots_info.php  HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "188.165.242.24"

Ktos pomoze?
Awatar użytkownika
redelek
Posty: 89
Rejestracja: 19 marca 2007, 13:45

Post autor: redelek »

Jak możesz to zmień w pliku /etc/nginx/sites-available/default
tą linijkę :

Kod: Zaznacz cały

/var/www/default$script;
na to

Kod: Zaznacz cały

/var/www/default/$script;
i zobacz czy zadziała.
kozikowski11
Posty: 6
Rejestracja: 02 lutego 2011, 00:23

Post autor: kozikowski11 »

Nie pomogło nic. Ale to jest ciekawe, bo kiedy skrypt jest wykonywany inny już nie może.

Kod: Zaznacz cały

Oczekiwanie...
to mówi mi przeglądarka. Kiedy zakończę wykonywanie skryptu, kolejny może działać. Wygląda na to jakby php obsługiwało tylko jeden skrypt w jednym momencie. Może ja mam jakiś nie fart i coś źle konfiguruję?

Mam nadzieję, że Wy coś wymyślicie.

Pozdrawiam.
Awatar użytkownika
Bastian
Member
Posty: 1424
Rejestracja: 30 marca 2008, 16:09
Lokalizacja: Poznañ

Post autor: Bastian »

Spójrz tu
ODPOWIEDZ