开发者

how to write c++ webservice in linux machine using fast_cgi module where apache being the webserver

I am looking at writing c++ webservice for linux with apache being the webserver.i am working on linux for first time so i needed your help.

Am following the instructions given by Fast_Cgi site.

  • I have downloaded the toolkit "mod_fast_cgi-2.4.6.tar.tar" from the site " http://www.fastcgi.com/drupal/".
  • Then i followed the instructions given 开发者_运维知识库in "INSTALL.AP2" file which is present in toolkit.

  • I was able to generate “fast_cgi.so file”. Now this file is located in my directory

Configuring httpd.conf

next step is to make changes in my

In http.conf file –

I have added "LoadModule fastcgi_module modules/mod_fastcgi.so" in the begining of the httpd.conf file

then they have said to add these things before virtual host directive

<IfModule mod_fastcgi.c>

   FastCgiIpcDir /tmp/fcgi_ipc/

   AddHandler fastcgi-script .fcgi

</IfModule>

Sample C++ program

my test program "Testwebservice.cpp" looks like this

#include "fcgi_stdio.h" /* fcgi library; put it first*/
#include <stdlib.h>

int count;

void initialize(void)
{
    count=0;
}

int main(void)
{
    /* Initialization. */  
    initialize();

    /* Response loop. */
    while (FCGI_Accept() >= 0)   {
        printf("Content-type: text/html\r\n"
                "\r\n"
                "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
                "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
                "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("SERVER_HOSTNAME"));
    }

    return 0;

}

I feel am missing something in the directive which i added just before the virtual host directive.

could you help me to know what am i missing here.

what is that i have to add in httpd.conf file which will direct the http requests coming to the apache webserver to my c++ application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜