nginx+spawn-fcig+fastcgi+c++

首席吹牛官 发布于 2014/10/17 23:52
阅读 1K+
收藏 1

各位好,我使用nginx+fastcgi+c++,基于web http协议来进行客户端和服务器端的交互,我又两个cgi程序,分别为1.cgi和2.cgi,已经其中,我希望url路径中包含fcgi1.cgi,将请求交给1.cgi,对于2同理.

我的nginx配置

#nginx run on user group
user  zhou adm;

# number of worker processes
worker_processes  2;

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

error_log /home/zhou/nginx/log/error.log info;

pid        /home/zhou/nginx/nginx.pid;


worker_rlimit_nofile 50000;

events {
    use epoll;
    worker_connections  50000;
    
}


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;
    tcp_nodelay    on;

    #keepalive_timeout  0;
    keepalive_timeout  120;

    gzip  on;
    gzip_comp_level 2;
    
    gzip_types text/plain application/x-javascript text/css application/xml;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        
        
        #C/C++ cgi program
        #location ~ \.cgi$ {
        #   fastcgi_pass   127.0.0.1:9080;
        #   fastcgi_index  index.cgi;
        #   fastcgi_param  SCRIPT_FILENAME  fastcgi_temp$fastcgi_script_name;
        #   include        fastcgi_params;
        #}

        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
        
        
         location /fcgi1.cgi$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.cgi;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
        
        location /fcgi2.cgi$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_index  index.cgi;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        #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$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


但是当我操作是,输入http://127.0.0.1/fcgi1.cgi时,没有执行

看log

2014/10/17 23:42:42 [error] 12434#0: *2 open() "/usr/local/nginx/html/fcgi1.cgi" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /fcgi1.cgi HTTP/1.1", host: "127.0.0.1"
2014/10/17 23:44:37 [info] 12434#0: *2 client 127.0.0.1 closed keepalive connection

请教我配置那里有问题


加载中
0
mickelfeng
mickelfeng
server 块下面加个root xxx,location /xxxx$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.cgi;
            fastcgi_param  SCRIPT_FILENAME  /xxx$fastcgi_script_name;
            include        fastcgi_params;
        }
lios
lios
回复 @China首席吹牛官 : 请问搞定了吗?
首席吹牛官
首席吹牛官
小弟刚接触nginx不是,很明白啊
返回顶部
顶部