木槿巴巴

ngnix and fastcgi and cicstg 开发环境搭建

一个搭建HTTP Server的项目需求,虽然方案没有最终确定,使用Ngnix做代理转发,后端使用使用开发语言无关的CGI应用进行业务逻辑处理,初步技术是可行的。但使用C语言开发WebServer 应用或许真不是什么好主意,那这样想啊,我们还用CICS这么古老的东西呢?–这里又忍不住想吐槽cics了..这个架构中的毒瘤!…. 进入正题吧,首先安装ngnix,ngnix的强大就不用叨叨了,安装也相当顺利。

# wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
# ./configure;make;make install;
# wget http://nginx.org/download/nginx-1.10.2.tar.gz
# ./configure;make;make install;

这样就可以启动nginx,默认安装在了/usr/local/nginx目录下.

libXp.i686 
glibc-devel.i686

–慢慢享受其中的酸爽吧%$%$%.

 while (FCGI_Accept() >= 0) {   
        memset(sBufIn,0,sizeof(sBufIn));
        FCGI_fread(sBufIn, sizeof(char), sizeof(sBufIn), FCGI_stdin);
        if(strlen(sBufIn)==0)
        {
            memcpy(sBufIn,sParmas,strlen(sParmas));
        }
        memset(&tHttpIn,0x00,sizeof(HttpReqT));
        rc=InitHttpIn(&tHttpIn,sBufIn);
        resultSize= URLDecode(tHttpIn.MsgIn, tHttpIn.MsgIn, sizeof(tHttpIn.MsgIn));
        rc=CallCtgSvr(&tHttpIn);
        if(rc != RC_OK)
        {
            printf("Content-type: text/plain\r\n"
                "\r\n"
                ""
                "QUERY_STRING :%s.\n"
                "REQUEST_METHOD : %s.\n"
                "CONTENT_TYPE : %s.\n"
                "CONTENT_LENGTH : %s.\n"
                "SERVER_PROTOCOL : %s.\n"
              ...
         }
         ...
     }
     // CTG 调用函数
     // CTG_openRemoteGatewayConnection();
     // CTG_ECI_Execute(gatewayToken, &eciParms);
     // Makefile libs -m64 -lctgclient -lfcgi
 location ~ \.cgi$ {
        fastcgi_pass 127.0.0.1:8000;
        fastcgi_index index.cgi;
        fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;
        include fastcgi_params;
    }
 #!/usr/bin/env python
#coding=utf8
import httplib, urllib
httpClient = None
try:
    #params = urllib.urlencode({'name': 'tom', 'age': 22})
    params = '''TEST CTG..'''
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    httpClient = httplib.HTTPConnection("192.168.101.181", 80, timeout=30)
    httpClient.request("POST", "/ctgcls.cgi", params, headers)
    response = httpClient.getresponse()
    print response.status
    print response.reason
    print response.read()
    print response.getheaders() #获取头信息
except Exception, e:
    print e
finally:
    if httpClient:
        httpClient.close() 
Exit mobile version