Windows Apache and C + + implements the first fastcgi__c++

Source: Internet
Author: User
Tags strcmp

For more information, please see: http://www.16boke.com


by ZXY,QQ Group: 168424095

Configuration of httpd.conf in Apache

(1) scriptalias/cgi-bin/"D:/program files/apache Software foundation/apache2.2/cgi-bin/"
Instead: scriptalias/cgi-bin/"f:/app/cgi/"

(2) <directory "D:/program files/apache Software Foundation/apache2.2/cgi-bin" >
AllowOverride None
Options None
Order Allow,deny
Allow from all
</Directory>
To
<directory "f:/app/cgi" >
#SetHandler Fastcgi-script
#SetHandler Cgi-script
#SetHandler Fcgid-script
AllowOverride None
#Options None
Options +execcgi
Order Allow,deny
Allow from all
</Directory>

(3) Increase in the last side:
LoadModule Fcgid_module modules/mod_fcgid.so

<ifmodule mod_fcgid.c>
AddHandler Fcgid-script. fcgi
Socketpath/tmp/fcgid.sock
Timeout 1000
#Action php-fastcgi/cgi-bin/
#AddType application/x-httpd. fcgi
</IfModule>

It turns out that one of the fastcgi that really helps me online is:
#include "fcgi_stdio.h"
#include "Fcgiapp.h"
#include <stdlib.h>
#include <string.h>

int main () {
Fcgx_stream *in, *out, *err;
Fcgx_paramarray envp;
char* Request_method;
Char* content_length;
Char* query_string;
int Len;
Char buffer[1024];
while (Fcgx_accept (&in, &out, &err, &AMP;ENVP) >= 0) {
fcgx_fprintf (out, "content-type:text/html\r\n\r\n");
Request_method = Fcgx_getparam ("Request_method", ENVP);
if (strcmp (Request_method, "POST") = = 0) {
Content_length = Fcgx_getparam ("Content_length", ENVP);
if (content_length!= NULL) {
len = 0;
Len = Strtol (Content_length, NULL, 10);
if (len = = 0) {
fcgx_fprintf (out, "No data from Standard input.\n");
}else{
FCGX_GETSTR (buffer, 1024, in);
Buffer[len-1] = ' the ';
fcgx_fprintf (out, "%s\n", buffer);
}
}
}else if (strcmp (Request_method, "get") = = 0) {
Query_string = Fcgx_getparam ("query_string", ENVP);
fcgx_fprintf (out, "%s\n", query_string);
}
}
return 0;
}

Apache Configuration

Include and Lib for the fastcgi used

Httpd-2.2.19-win32-x86-openssl-0.9.8r.zip

Mod_fcgid.so


For more information, please see: http://www.16boke.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.