Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 

Fastcgi

A simple C++ implementation of fastcgi protocol which enables you to write your web application logic in C++.

Usage

Implementing a fastcgi application is easy, one should first create a class that inherits responder, then server class that accepts incoming requests.

#include "../server.h"
#include "../responder.h"
#include <string.h>

class helloWorld : public fastcgi::responder
{
public:
    void respond()
    {
        const char *test =
                "Content-Type: text/html\n"
                        "Content-Length: 115\n"
                        "\n"
                        "<!DOCTYPE html>\n"
                        "<html>\n"
                        "\t<head>\n"
                        "\t\t<title>Wellcome!</title>\n"
                        "\t</head>\n"
                        "\t<body>\n"
                        "\t\t<h1>Hello World!</h1>\n"
                        "\t</body>\n"
                        "</html>";
        writeBody(test, strlen(test));
    };
};

int main(int argc, char * argv[])
{
    fastcgi::server app(new helloWorld);
    app.accept();
    return 0;
}

You must run the application yourself and point the web sever to which port server is listening (default is 8080).

Simple Nginx configuration that should work with fastcgi:

server {
    listen 80;
    server_name localhost;
    
    location / {
        include fastcgi_params;
        fastcgi_pass localhost:8080;
    }
}

Building

The build system is CMake and there should be no problem building on Linux. MS Windows is not supported yet.

First clone:

$ git clone https://github.com/rabbanian/fastcgi.git

Then make a build directory:

$ mkdir fastcgi/build/
$ cd fastcgi/build/

Run CMake:

$ cmake ..

And Make:

$ make

About

Multithreaded fastcgi application server

Topics

Resources

License

Releases

No releases published

Packages

No packages published