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