Skip to content

Multithreaded fastcgi application server

License

Notifications You must be signed in to change notification settings

rabbanian/fastcgi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Stars

Watchers

Forks

Releases

No releases published

Packages