FastCGI program written in C

Source: Internet
Author: User

I recently came into contact with the web page. I heard that I can write web pages in C language, so I burst into the dark and went to the anti-literacy class...

First install FastCGI development kit...

# Wget http://www.fastcgi.com/dist/fcgi-current.tar.gz

# Tar-zxvf fcgi-current.tar.gz

# Cd fcgi-2.4.0

#./Configure -- prefix =/usr/local/FastCGI/

# Make & make install

Write a simple fcgi Program

# Vim hello. c

The content is as follows:

#include </usr/local/fastcgi/include/fcgi_stdio.h>int main(void){    while( FCGI_Accept() >= 0){        printf( "Content-Type: text/html\r\n" );        printf("\r\n");        printf( "Hello world in C\n" );    }}

# Gcc-O hello. fcgi hello. C-L/usr/local/FastCGI/lib/-lfcgi

Modify the configuration of nginx. conf.

server {listen 80;location ~ \.fcgi$ {            root           /srv/www;            fastcgi_pass   127.0.0.1:9002;            include        fastcgi_params;}}

Restart nginx, use FastCGI to start the program, and listen to port 9002.

#/Usr/local/FastCGI/bin/cgi-fcgi-start-connect 127.0.0.1: 9002/srv/html/cgi/Hello. fcgi

It should be accessible ..

Http://qzier.com/cgi/hello.fcgi

It is still relatively weak. I have established a QQ group and hope to gather together to learn and exchange.

Linux & C, PHP, PostgreSQL, nginx, O & M, and security

QQ: 213572677

Reference:

Http://www.kutukupret.com/2010/08/20/nginx-fastcgi-hello-world-in-c/

Further Optimization

Https://writer.zoho.com/public/6b6a49b6dcbb8205336873dd09e1b3517a451cd1e1176acb55cc7a120224dc4a6db04614eed231e5

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.