SORU
4 NİSAN 2012, ÇARŞAMBA


PHP-FPM ve Nginx: 502 Bad Gateway

Yapılandırma

  • Ubuntu Server 11.10 64 bit
  • Amazon BÖLÜM, Ec2, bulut ev sahipliği yaptı
  • t1.mikro örneği

Başka bir şey yazmadan önce, nginx 502 bad gateway ve ne yazık ki bu konuda bana yardımcı değil Nginx PHP-FPM 502 Bad Gatway konuları, her ikisi de kontrol ettim belirtmek isterim.

Sorunu oldukça yaygın görünüyor: nginx bir yanlış yapılandırma veya php-ROM kurtulmak mümkün değil bir şey 502 Bad Gatway bir hata neden olabilir. Bu görünürbenim etki alanı kök gittim bileherhangi bir belirli dizin belirtmeden.

Amazon ec2 bir Web sunucusu, etkin, bağlantı noktası 80'i açın, vb bağlantı noktası 9000 ile koşuyorum.

Özellikle soru, nasıl bu pis hata kurtulabilirim? Ya da, daha iyisi, nasıl php5-fpm alabilir miyimaslında iş.

Şimdiye kadar denemedim

Çoğunlukla yapılandırma dosyaları tutarlı düzenleme, php-fpm.conf nginx.conf oldukça büyük.

ben.php-ROM.conf

Oldukça fazla faydası olmadı aşağıdakilerden hangisi, ekledim:

;;;;;;;;;;;;;
; Fpm Start ;
;;;;;;;;;;;;;

;pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35

Şimdi, daha sonra yapılandırma dosyaları da dahil olmak üzere çalıştım:

include=/etc/php5/fpm/*.conf

Sadece daha da bana kazık attı.

Tam Yapılandırma

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p arguement)
;  - /usr otherwise
;include=/etc/php5/fpm/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /var/run/php5-fpm.pid

; Error log file
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when 
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = no

;;;;;;;;;;;;;
; Fpm Start ;
;;;;;;;;;;;;;

;pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ; 
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf

ıı.nginx.conf

Açıkçası bu yapılandırma ziyaret ettim, ama bu 502 Bad Gateway iş önce, sunucu iyi durumda olduğunu söyleyebilirim birkaç web siteleri (PHP olmadan çalışıyor. çat Pat. Dönem.).

Bu konuda öncelikle bir şey olması çok ama çok yanlış yatıyor. Ve şimdi, bir service php5-fpm restart, tahmin ediyorum ne kilitleniyor yapmaya çalıştığımda sonsuz bir döngüye veya bile edemeyeceğim bir şeyCTRL-Cdışarı.

Tam Yapılandırma

user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
    worker_connections 64;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush off;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

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

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {
        listen 80;
        server_name ec2-xx-xx-xx-xx.compute-x.amazonaws.com;

        location ~ ^(. \.php)(.*)$ {
            root   /home/wayvac/public;
            fastcgi_pass   unix:/var/run/php5-fpm.pid;  
            #fastcgi_pass   127.0.0.1:9000; #Un-comment this and comment "fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;" if you are not using php-fpm.
            fastcgi_index  index.php;
            set $document_root2 $document_root;
            if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }
            if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }
            if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }
            if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }
            if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }
            fastcgi_split_path_info ^(. \.php)(.*)$;
            fastcgi_param   SCRIPT_FILENAME $document_root2$fastcgi_script_name;
            fastcgi_param   PATH_INFO   $fastcgi_path_info;
            fastcgi_param   PATH_TRANSLATED $document_root2$fastcgi_path_info;
            include fastcgi_params;
            fastcgi_param  DOCUMENT_ROOT      $document_root2;
        }       

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

        location / {
            root /home/wayvac/public;   
            index index.html index.htm index.php;
        }

        location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
            # Some basic cache-control for static files to be sent to the browser
            expires max;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        #include drop.conf;
        #include php.conf;
    }
}

CEVAP
28 Ocak 2013, PAZARTESİ


Eğer herkes aynı sorunla karşılaşmış Bu sayfa bulursa, cevabı buldum burada: http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-lemp-on-ubuntu-12.04-lts

Rahatsız olamaz olanlar tıklatın ve kendileri için çalışması için... ;)

Durum:

NGİNX ve PHP 5.3 ile Ubuntu ya da Debian server gayet iyi çalışıyor ama 5.4 PHP yükseltme 502 Bad Gateway hata veriyor. Hizmet bağlantı noktası 9000 çalışan (genellikle netstat -lp veya benzeri bir çalışan için bir şey verir.

Düzeltme:

/etc/php5/fpm/pool.d/www.conf açın ve not alın '' parametre (benim durumumda /var/run/php5-fpm.sock): . dinle

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php5-fpm.sock

ve az önce söylediğin yeri ile konak içinde fastcgi_pass değişkeni değiştirin.

Bu yüzden bu örnek symfony2 yapılandırma (buradan alındı: http://wiki.nginx.org/Symfony):

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ ^/(app|app_dev)\.php(/|$) {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_split_path_info ^(. \.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS              off;
  }

bu olur:

  # pass the PHP scripts to FastCGI server at /var/run/php5-fpm.sock
  location ~ ^/(app|app_dev)\.php(/|$) {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_split_path_info ^(. \.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  HTTPS              off;
  }

Daha sonra nginx restart:

sudo /etc/init.d/nginx restart

Not:eğer SF2 ** eğer ~ ^/index\.php(/|$) { 23* değiştirin

Bu kimse biraz zaman:) kaydeder umarım

Edit

Tabii ki, değişebilir listen = /var/run/php5-fpm.sock listen = 127.0.0.1:9000 /etc/php5/fpm/pool.d/www.conf yeniden php5-ROM (hangi tasarruf olmak üzere değiştirmek için kullanır), ama sen içeriye değiştirdiler php5-ROM çalıştırın üzerinden bir soket yerine dinlediği bağlantı noktası 9000 için bir sebep.

Edit2

Eğer hala 502 yaşıyorsanız hata bu cevaba bakınız: nginx error connect to php5-fpm.sock failed (13: Permission denied)

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Air_Fooj

    Air_Fooj

    24 NİSAN 2009
  • pjtoohot

    pjtoohot

    15 NİSAN 2008
  • xiaoyu85

    xiaoyu85

    20 ŞUBAT 2010