zoukankan      html  css  js  c++  java
  • nginx通过spawn-fcgi调用C++写的cgi程序

    通过apt-get install 安装nginx和spawn-fcgi

    /usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9002 -C 25 -f /usr/local/nginx/cgibin/lzgFastCGI

    参数含义如下:

    -f 指定调用FastCGI的进程的执行程序位置,根据系统上所装的PHP的情况具体设置
    -a 绑定到地址addr
    -p 绑定到端口port
    -s 绑定到unix socket的路径path
    -C 指定产生的FastCGI的进程数,默认为5(仅用于PHP)
    -P 指定产生的进程的PID文件路径
    -u和-g FastCGI使用什么身份(-u 用户 -g用户组)运行,Ubuntu下可以使用www-data,其他的根据情况配置,如nobody、apache等

    配置nginx.conf

    location ~ ^/charge-cgi/.*$ {


    location ~ charge-cgi$ {

    # With php5-cgi alone:
    fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    #fastcgi_pass unix:/var/run/php5-fpm.sock;

    if ($document_uri ~ "^/fbtestadmin/(.*)") {
    set $apache_path_info /$1;
    }
    fastcgi_param PATH_INFO $apache_path_info;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    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;

    }

    使用curl测试:

    curl -d "param1=value1&param2=value2" "http://192.168.15.226/charge-cgi" -G

    curl -d "param1=value1&param2=value2" "http://192.168.15.226/charge-cgi" 

    reference:

    http://redmine.webtoolkit.eu/boards/2/topics/6065

    http://wiki.nginx.org/FcgiExample

    http://wiki.nginx.org/NginxHttpCoreModule#location

  • 相关阅读:
    1130 host '***' is not allowed to connect to this MySQL server
    签名时出错,未能对....ext签名。SignTool Error: No certificates...
    C# 进制转换(二进制、十六进制、十进制互转)
    在安装32位Oracle客户端组建的情况下以64位模式运行
    Vue中引入jQuery
    sql server数据库分离时,数据库右侧显示(单个用户)
    解决Typora图片显示问题
    Ruby日文手册翻译1
    Boost Graph Library 库小结1
    归并排序
  • 原文地址:https://www.cnblogs.com/zsummer/p/4398783.html
Copyright © 2011-2022 走看看