V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
kmdd33
V2EX  ›  NGINX

请教运维小伙伴: connect() failed (111: Connection refused) while connecting to upstream

  •  
  •   kmdd33 · 2018-06-12 20:23:39 +08:00 · 3125 次点击
    这是一个创建于 2356 天前的主题,其中的信息可能已经有所发展或是发生改变。

    安装环境:openresty,php7,mysql,centos7 出现的问题:IP,ip / test.html 和 ip/50x.html 都显示正常,但是 ip/info.php 无法显示,并且无法进入安装程序目录。请问如何解决?

    error.log 显示错误:

    2018/06/09 09:46:56 [error] 825#825: *123 connect() failed (111: Connection refused) while connecting to upstream, client: 113.118.xxx.228, server: 173.255.247.37, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.255.xxx.xxx"

    目前 nginx.conf 的配置是:

    user root; worker_processes 1;

    #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;

    #pid logs/nginx.pid;

    events { worker_connections 1024; }

    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;
    
    client_max_body_size 8m;    #允许客户端请求的最大单文件字节数
    client_body_buffer_size 2m;  #缓冲区代理缓冲用户端请求的最大字节
    fastcgi_buffers 8 16k; 
    fastcgi_buffer_size 32k;
    

    #WAF lua_shared_dict limit 50m; #防 cc 使用字典,大小 50M lua_shared_dict guard_dict 100m; lua_shared_dict dict_captcha 70m; lua_max_running_timers 1; lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua"; init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua"; access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua";

    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    gzip  on;
    
    server {
        
        listen       127.0.0.1;
        server_name  my.server.ip.address;
        
        #charset koi8-r;
    
        #access_log  logs/host.access.log  main;
    
        location / {
    
            root    html;
            index  index.html index.htm index.php;
        }
    
    
        location /phpmyadmin {
            alias /usr/share/phpMyAdmin;
            index index.php;
         }
    
       location ~ /phpmyadmin/.+\.php$ {
            if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
             set $valid_fastcgi_script_name $1;
            }
             include fastcgi_params;
             fastcgi_pass 127.0.0.1:9000;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
         }
    
       
    
        #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   html;
        }
    
        # 这里新加的
        # PHP 脚本请求全部转发到 FastCGI 处理. 使用 FastCGI 协议默认配置.
        # Fastcgi 服务器和程序(PHP,Python)沟通的协议.
        location ~ \.php$ {
            # 设置监听端口
            fastcgi_pass   127.0.0.1:9000;
            # 设置 nginx 的默认首页文件(上面已经设置过了,可以删除)
            fastcgi_index  index.php;
            # 设置脚本文件请求的路径
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            # 引入 fastcgi 的配置文件
            include        fastcgi_params;
        }
    
        # 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           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /document_root$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;
        #}
    }
    
    
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    
    
    # HTTPS server
    
    server {
        listen  443 ssl http2;
        
        server_name  my.server.ip.address;
        charset  utf-8;
      #  ssl on;
        default_type  text/plain;
        
       
       
    
       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
       ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
       ssl_prefer_server_ciphers  on;
    
       location / {
            root   html;
           index  index.html index.htm index.php;
        }
    
         location ~ /phpmyadmin/.+\.php$ {
            if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
             set $valid_fastcgi_script_name $1;
            }
             include fastcgi_params;
             fastcgi_pass 127.0.0.1:9000;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
         }
    
       location ~ \.php$ {
            # 设置监听端口
            fastcgi_pass   127.0.0.1:9000;
            # 设置 nginx 的默认首页文件(上面已经设置过了,可以删除)
            fastcgi_index  index.php;
            # 设置脚本文件请求的路径
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            # 引入 fastcgi 的配置文件
            include        fastcgi_params;
        }
    

    }

    }

    / etc / php-fpm.d / www.conf 里面我添加了:

    listen = 127.0.0.1

    4 条回复    2018-07-16 07:04:46 +08:00
    kmdd33
        1
    kmdd33  
    OP
       2018-06-12 20:41:40 +08:00
    输入:netstat -lntp | grep 9000

    没有任何提示
    xuyl
        2
    xuyl  
       2018-06-13 00:10:31 +08:00
    检查 php-fpm 服务是否运行
    kmdd33
        3
    kmdd33  
    OP
       2018-06-13 17:38:31 +08:00
    @xuyl php-fpm 是运行的状态
    mytsing520
        4
    mytsing520  
       2018-07-16 07:04:46 +08:00
    检查 php-fpm 使用的端口
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2819 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 09:39 · PVG 17:39 · LAX 01:39 · JFK 04:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.