{"id":2004,"date":"2016-11-15T11:34:17","date_gmt":"2016-11-15T03:34:17","guid":{"rendered":"http:\/\/www.gigiwangs.com\/?p=2004"},"modified":"2016-11-15T11:34:17","modified_gmt":"2016-11-15T03:34:17","slug":"ngnix-and-fastcgi-and-cicstg-%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.mujins.com\/?p=2004","title":{"rendered":"ngnix and fastcgi and cicstg \u5f00\u53d1\u73af\u5883\u642d\u5efa"},"content":{"rendered":"<p>\u4e00\u4e2a\u642d\u5efaHTTP Server\u7684\u9879\u76ee\u9700\u6c42\uff0c\u867d\u7136\u65b9\u6848\u6ca1\u6709\u6700\u7ec8\u786e\u5b9a\uff0c\u4f7f\u7528Ngnix\u505a\u4ee3\u7406\u8f6c\u53d1\uff0c\u540e\u7aef\u4f7f\u7528\u4f7f\u7528\u5f00\u53d1\u8bed\u8a00\u65e0\u5173\u7684CGI\u5e94\u7528\u8fdb\u884c\u4e1a\u52a1\u903b\u8f91\u5904\u7406\uff0c\u521d\u6b65\u6280\u672f\u662f\u53ef\u884c\u7684\u3002\u4f46\u4f7f\u7528C\u8bed\u8a00\u5f00\u53d1WebServer \u5e94\u7528\u6216\u8bb8\u771f\u4e0d\u662f\u4ec0\u4e48\u597d\u4e3b\u610f\uff0c\u90a3\u8fd9\u6837\u60f3\u554a\uff0c\u6211\u4eec\u8fd8\u7528CICS\u8fd9\u4e48\u53e4\u8001\u7684\u4e1c\u897f\u5462\uff1f\u2013\u8fd9\u91cc\u53c8\u5fcd\u4e0d\u4f4f\u60f3\u5410\u69fdcics\u4e86..\u8fd9\u4e2a\u67b6\u6784\u4e2d\u7684\u6bd2\u7624\uff01\u2026. \u8fdb\u5165\u6b63\u9898\u5427\uff0c\u9996\u5148\u5b89\u88c5ngnix\uff0cngnix\u7684\u5f3a\u5927\u5c31\u4e0d\u7528\u53e8\u53e8\u4e86\uff0c\u5b89\u88c5\u4e5f\u76f8\u5f53\u987a\u5229\u3002<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5b89\u88c5PCRE<\/li>\n<\/ul>\n<pre class=\"brush:bash\"># wget  ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-8.39.tar.gz\n# .\/configure;make;make install;<\/pre>\n<ul>\n<li>\u4e0b\u8f7d\u5b89\u88c5nginx-&gt;<a href=\"http:\/\/nginx.org\/\">[\u8fd9\u91cc]<\/a><\/li>\n<\/ul>\n<pre class=\"brush:bash\"># wget http:\/\/nginx.org\/download\/nginx-1.10.2.tar.gz\n# .\/configure;make;make install;<\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u542f\u52a8nginx\uff0c\u9ed8\u8ba4\u5b89\u88c5\u5728\u4e86<code class=\"highlighter-rouge\">\/usr\/local\/nginx<\/code>\u76ee\u5f55\u4e0b.<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5b89\u88c5spawn-fcgi,\u53ef\u4ee5\u4eceGithub Lighthtpd\u9879\u76ee\u4e2d\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4ece<a href=\"http:\/\/blog.lighttpd.net\/articles\/2009\/09\/23\/spawn-fcgi-1-6-3-released\/\">lighttpd.net\u8fd9\u91cc<\/a>\u4e0b\u8f7d\u3002\u540c\u6837\u53ef\u4ee5\u7f16\u8bd1\u51fa<code class=\"highlighter-rouge\">Spawn-fcgi<\/code>\u8fd9\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\u3002ngnix\u662f\u652f\u6301FastCgi\u7684\uff0c\u4f46\u662f\u6ca1\u6709\u8fd9\u4e2aCGI\u7ba1\u7406\u7a0b\u5e8f\u3002<\/li>\n<li>\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5199CGI\u7a0b\u5e8f\u4e86\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u73b0\u6210\u5f00\u6e90\u5e93\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5199\u3002<\/li>\n<li>\u5b89\u88c5CICS TRANSACTION GATEWAY\uff0c!!!NOTE!!![\u8fd9\u73a9\u610f\u57fa\u672c\u4e0a\u652f\u630132\u7cfb\u7edf\uff0c\u5b89\u88c5\u65f6\u4e5f\u4f1a\u5404\u79cd\u6c34\u571f\u4e0d\u670d\u7684\uff0c\u4f60\u53ef\u80fd\u9700\u898132\u4f4d\u7684jre..]\u5b89\u88c5\u5f00\u53d1\u4e2d\u53ef\u80fd\u9700\u898132\u4f4d\u652f\u6301\uff0c\u6bd4\u5982:<\/li>\n<\/ul>\n<pre class=\"brush:bash\">libXp.i686 \nglibc-devel.i686<\/pre>\n<p>\u2013\u6162\u6162\u4eab\u53d7\u5176\u4e2d\u7684\u9178\u723d\u5427%$%$%.<\/p>\n<ul>\n<li>\u987a\u5229\u7684\u8bdd\u5e94\u8be5\u53ef\u4ee5\u5199\u4ee3\u7801\u6d4b\u8bd5\u4e00\u4e0b\u4e86\u3002\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u662f\u63a5\u53d7\u4ece\u6d4f\u89c8\u5668\u63d0\u4ea4\u7684\u8868\u5355\u7136\u540e\u63d0\u4ea4CTG\u8bf7\u6c42\uff0c\u7f16\u5199\u4ee3\u7801\u7f16\u8bd1\u3002<\/li>\n<\/ul>\n<pre class=\"brush:c\"> while (FCGI_Accept() &gt;= 0) {   \n        memset(sBufIn,0,sizeof(sBufIn));\n        FCGI_fread(sBufIn, sizeof(char), sizeof(sBufIn), FCGI_stdin);\n        if(strlen(sBufIn)==0)\n        {\n            memcpy(sBufIn,sParmas,strlen(sParmas));\n        }\n        memset(&amp;tHttpIn,0x00,sizeof(HttpReqT));\n        rc=InitHttpIn(&amp;tHttpIn,sBufIn);\n        resultSize= URLDecode(tHttpIn.MsgIn, tHttpIn.MsgIn, sizeof(tHttpIn.MsgIn));\n        rc=CallCtgSvr(&amp;tHttpIn);\n        if(rc != RC_OK)\n        {\n            printf(\"Content-type: text\/plain\\r\\n\"\n                \"\\r\\n\"\n                \"\"\n                \"QUERY_STRING :%s.\\n\"\n                \"REQUEST_METHOD : %s.\\n\"\n                \"CONTENT_TYPE : %s.\\n\"\n                \"CONTENT_LENGTH : %s.\\n\"\n                \"SERVER_PROTOCOL : %s.\\n\"\n              ...\n         }\n         ...\n     }\n     \/\/ CTG \u8c03\u7528\u51fd\u6570\n     \/\/ CTG_openRemoteGatewayConnection();\n     \/\/ CTG_ECI_Execute(gatewayToken, &amp;eciParms);\n     \/\/ Makefile libs -m64 -lctgclient -lfcgi\n<\/pre>\n<ul>\n<li>\u914d\u7f6enginx \u7aef\u53e3\u8f6c\u53d1\u5904\u7406FASTCGI.<\/li>\n<\/ul>\n<pre class=\"brush:bash\"> location ~ \\.cgi$ {\n        fastcgi_pass 127.0.0.1:8000;\n        fastcgi_index index.cgi;\n        fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;\n        include fastcgi_params;\n    }<\/pre>\n<ul>\n<li>\u914d\u7f6enginx \u7aef\u53e3\u8f6c\u53d1\u5904\u7406FASTCGI.\u542f\u52a8CGI\u7a0b\u5e8f\u3002\n<pre class=\"brush:bash\"> \/usr\/local\/nginx\/sbin\/spawn-fcgi -a 127.0.0.1 -p 8000 -f \/usr\/local\/nginx\/cgi-bin\/ctgcls<\/pre>\n<\/li>\n<li>\u4f7f\u7528\u6d4f\u89c8\u5668\u6d4b\u8bd5\u6216\u5176\u4ed6HTTP \u5ba2\u6237\u7aef\u7a0b\u5e8f\u6d4b\u8bd5<\/li>\n<\/ul>\n<pre class=\"brush:python\"> #!\/usr\/bin\/env python\n#coding=utf8\nimport httplib, urllib\nhttpClient = None\ntry:\n    #params = urllib.urlencode({'name': 'tom', 'age': 22})\n    params = '''TEST CTG..'''\n    headers = {\"Content-type\": \"application\/x-www-form-urlencoded\", \"Accept\": \"text\/plain\"}\n    httpClient = httplib.HTTPConnection(\"192.168.101.181\", 80, timeout=30)\n    httpClient.request(\"POST\", \"\/ctgcls.cgi\", params, headers)\n    response = httpClient.getresponse()\n    print response.status\n    print response.reason\n    print response.read()\n    print response.getheaders() #\u83b7\u53d6\u5934\u4fe1\u606f\nexcept Exception, e:\n    print e\nfinally:\n    if httpClient:\n        httpClient.close() \n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2a\u642d\u5efaHTTP Server\u7684\u9879\u76ee\u9700\u6c42\uff0c\u867d\u7136\u65b9\u6848\u6ca1\u6709\u6700\u7ec8\u786e\u5b9a\uff0c\u4f7f\u7528Ngnix\u505a\u4ee3\u7406\u8f6c\u53d1\uff0c\u540e\u7aef\u4f7f\u7528\u4f7f\u7528\u5f00\u53d1\u8bed\u8a00\u65e0\u5173\u7684CGI\u5e94\u7528\u8fdb\u884c\u4e1a\u52a1\u903b\u8f91\u5904\u7406\uff0c\u521d\u6b65\u6280\u672f\u662f\u53ef\u884c\u7684\u3002\u4f46\u4f7f\u7528C\u8bed\u8a00\u5f00\u53d1WebServer \u5e94\u7528\u6216\u8bb8\u771f\u4e0d\u662f\u4ec0\u4e48\u597d\u4e3b\u610f\uff0c\u90a3\u8fd9\u6837\u60f3\u554a\uff0c\u6211\u4eec\u8fd8\u7528CICS\u8fd9\u4e48\u53e4\u8001\u7684\u4e1c\u897f\u5462\uff1f\u2013\u8fd9\u91cc\u53c8\u5fcd\u4e0d\u4f4f\u60f3\u5410\u69fdcics\u4e86..\u8fd9\u4e2a\u67b6\u6784\u4e2d\u7684\u6bd2\u7624\uff01\u2026. \u8fdb\u5165\u6b63\u9898\u5427\uff0c\u9996\u5148\u5b89\u88c5ngnix\uff0cngnix\u7684\u5f3a\u5927\u5c31\u4e0d\u7528\u53e8\u53e8\u4e86\uff0c\u5b89\u88c5\u4e5f\u76f8\u5f53\u987a\u5229\u3002 \u4e0b\u8f7d\u5b89\u88c5PCRE # wget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-8.39.tar.gz # .\/configure;make;make install; \u4e0b\u8f7d\u5b89\u88c5nginx-&gt;[\u8fd9\u91cc] # wget http:\/\/nginx.org\/download\/nginx-1.10.2.tar.gz # .\/configure;make;make install; \u8fd9\u6837\u5c31\u53ef\u4ee5\u542f\u52a8nginx\uff0c\u9ed8\u8ba4\u5b89\u88c5\u5728\u4e86\/usr\/local\/nginx\u76ee\u5f55\u4e0b. \u4e0b\u8f7d\u5b89\u88c5spawn-fcgi,\u53ef\u4ee5\u4eceGithub Lighthtpd\u9879\u76ee\u4e2d\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4ecelighttpd.net\u8fd9\u91cc\u4e0b\u8f7d\u3002\u540c\u6837\u53ef\u4ee5\u7f16\u8bd1\u51faSpawn-fcgi\u8fd9\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f\u3002ngnix\u662f\u652f\u6301FastCgi\u7684\uff0c\u4f46\u662f\u6ca1\u6709\u8fd9\u4e2aCGI\u7ba1\u7406\u7a0b\u5e8f\u3002 \u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5199CGI\u7a0b\u5e8f\u4e86\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u73b0\u6210\u5f00\u6e90\u5e93\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5199\u3002 \u5b89\u88c5CICS TRANSACTION GATEWAY\uff0c!!!NOTE!!![\u8fd9\u73a9\u610f\u57fa\u672c\u4e0a\u652f\u630132\u7cfb\u7edf\uff0c\u5b89\u88c5\u65f6\u4e5f\u4f1a\u5404\u79cd\u6c34\u571f\u4e0d\u670d\u7684\uff0c\u4f60\u53ef\u80fd\u9700\u898132\u4f4d\u7684jre..]\u5b89\u88c5\u5f00\u53d1\u4e2d\u53ef\u80fd\u9700\u898132\u4f4d\u652f\u6301\uff0c\u6bd4\u5982: libXp.i686 glibc-devel.i686 \u2013\u6162\u6162\u4eab\u53d7\u5176\u4e2d\u7684\u9178\u723d\u5427%$%$%. \u987a\u5229\u7684\u8bdd\u5e94\u8be5\u53ef\u4ee5\u5199\u4ee3\u7801\u6d4b\u8bd5\u4e00\u4e0b\u4e86\u3002\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u662f\u63a5\u53d7\u4ece\u6d4f\u89c8\u5668\u63d0\u4ea4\u7684\u8868\u5355\u7136\u540e\u63d0\u4ea4CTG\u8bf7\u6c42\uff0c\u7f16\u5199\u4ee3\u7801\u7f16\u8bd1\u3002 while (FCGI_Accept() &gt;= 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(&amp;tHttpIn,0x00,sizeof(HttpReqT)); rc=InitHttpIn(&amp;tHttpIn,sBufIn); resultSize= URLDecode(tHttpIn.MsgIn, tHttpIn.MsgIn, sizeof(tHttpIn.MsgIn)); rc=CallCtgSvr(&amp;tHttpIn); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1727,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"aside","meta":[],"categories":[21,7],"tags":[24,13],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts\/2004"}],"collection":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2004"}],"version-history":[{"count":0,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/wp\/v2\/posts\/2004\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mujins.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}