Nginx 1.9与PHP5-FPM连接被拒绝

时间:2016-05-20 14:26:21

标签: php ubuntu nginx amazon-ec2

我花了好几个小时试图解决这个问题并阅读了很多文章,所有文章都没有解决问题。

我一直在:

*2 connect() failed (111: Connection refused) while connecting to upstream client: 81.xxx.xxx.xxx, server: localhost, request:"GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "52.xxx.xxx.xxx"

我在Amazon EC2微型实例上使用Ubuntu 14.4。

nginx.conf:

user  www-data;
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;

        server_tokens off;

        sendfile        on;
        tcp_nopush     on;
        tcp_nodelay on;

        client_body_timeout 12;
        client_header_timeout 12;
        keepalive_timeout 15;
        send_timeout 10;

        gzip on;
        gzip_proxied any;
        gzip_types text/plain text/xml text/css application/x-javascript;
        gzip_vary on;
        gzip_min_length  1100;
        gzip_buffers  4 32k;
        gzip_disable “MSIE [1-6]\.(?!.*SV1)”;

        open_file_cache max=5000 inactive=20s;
        open_file_cache_valid 30s;
        open_file_cache_min_uses 2;
        open_file_cache_errors on;

    server {
        listen       80 default_server;
        listen  443 ssl;

        server_name  localhost;

        index index.php index.html;

        ssl_certificate      /etc/ssl/cacert.pem;
        ssl_certificate_key  /etc/ssl/privkey.pem;

        ssl_session_cache    shared:SSL:20m;
ssl_session_timeout  180m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers  on;
        ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
        ssl_dhparam /etc/ssl/dhparam.pem;

        add_header Strict-Transport-Security "max-age=31536000" always;

        pagespeed on;
        pagespeed RewriteLevel CoreFilters;

        pagespeed FileCachePath              "/var/cache/pagespeed/";
        pagespeed FileCacheSizeKb            102400;
        pagespeed FileCacheCleanIntervalMs   3600000;
        pagespeed FileCacheInodeLimit        500000;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 365d;
        }

        location / {
            root   html;
        }

        #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;
        }

        # 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$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                #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;
        #}
    }
        client_body_buffer_size 10K;
        client_header_buffer_size 1k;
        client_max_body_size 8m;
        large_client_header_buffers 2 1k;

}

PHP5 FPM www.conf:

[www]

...
user = www-data
group = www-data


listen = /var/run/php5-fpm.sock
#listen = 127.0.0.1:9000
#listen = /tmp/php5-fpm.sock

listen.owner = www-data
listen.group = www-data
listen.mode = 0660
...

是什么导致了这个问题?

0 个答案:

没有答案