如何使用nginx和fastcgi的套接字

时间:2012-03-05 11:14:07

标签: sockets nginx fastcgi

我正在尝试使用套接字而不是tcp用于nginxfastcgi

下面是我对nginx的配置。如果我使用127.0.0.1:9001即tcp连接,它可以工作。

这是错误日志。

2012/03/06 22:04:53 [crit] 19328#0: *1 connect() to unix:/tmp/nginx9001.socket failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /pixel/ HTTP/1.1", upstream: "fastcgi://unix:/tmp/nginx9001.socket:", host: "127.0.0.1"

nginx conf:

location /pixel/ {
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            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;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            #fastcgi_pass 127.0.0.1:9001;
                    fastcgi_pass unix:/tmp/nginx9001.socket;
        }

这是我的spawn-fcgi脚本

exec spawn-fcgi -n -d /home/ubuntu/workspace/rtbopsConfig/rtbServers/ -s /tmp/nginx9001.socket -f /home/ubuntu/workspace/rtbopsConfig/rtbServers/index.py >> /var/log/test.sys.log 2>&1

1 个答案:

答案 0 :(得分:2)

PHP未配置为侦听unix套接字,它配置为侦听tcp套接字。更改您的PHP配置以匹配您想要的。