BUG:upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected


更換Apache撲向Nginx,剛搭建完WNMP,nginx能訪問php頁面 但是訪問現有開發項目報錯

1 [error] 4112#3724: *9 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond 
2 after a period of time, or established connection failed because connected host has failed to respond) while reading response header 
3 from upstream, client: 127.0.0.1, server: localhost, request: "GET /right/backend/web/index.php?r=api/get-products HTTP/1.1", 
4 upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"

通過探尋 找到原因 當前使用的是項目A,但是A調用了項目B(權限系統) 但是配置的Nginx時只固定了一個9000端口 A占用后;B就無法訪問

解決方案:

1.修改nginx.conf 添加端口(紅色部分)

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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
     keepalive_timeout  65;

    gzip  on;

    upstream fastcgi_backend { server 127.0.0.1:9001;
    server 127.0.0.1:9002;
    server 127.0.0.1:9003;
    server 127.0.0.1:9004;
    server 127.0.0.1:9005;
    server 127.0.0.1:9006;
    server 127.0.0.1:9007; }
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   D:/WNMP/nginx-1.10.3/html;
            index  index.html index.htm index.php;
            autoindex on; 
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   D:/WNMP/nginx-1.10.3/html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
        #    root           D:/WNMP/nginx-1.10.3/html;
 fastcgi_pass fastcgi_backend;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  D:/WNMP/nginx-1.10.3/html$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

2.如果使用快捷腳本啟動WNMP,腳本修改(可以將php nginx加入環境變量使用相對路徑,我用的絕對路徑哈,因為項目多,方便應用不同php版本)

@echo off
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9001  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9002  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9003  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9004  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9005  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9006  &
start /B  D:/WNMP/php7/php-cgi.exe -b 127.0.0.1:9007  &
start /B  D:/WNMP/nginx/nginx.exe

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM