The biggest advantage of fastcgi is that it is highly efficient, because once the program is loaded into memory, it stays on for a long time, and does not load up on the memory for every execution, like a normal program.
Because for the large number of visits, the actual implementation of relatively simple procedures, it is best to write a fastcgi way, can significantly improve the concurrency processing capacity.
Because Nginx does not bring fastcgi tools, we need lighttpd spawn-fcgi
Older versions of the spawn-fcgi are brought in lighttpd, and new versions can be installed independently. Older versions of the system need to first
Apt Install lighttpd
Do not let lighttpd run, or modify the LIGHTTPD default port
Vi/etc/lighttpd/lighttpd.conf
Server.port = 81
What we need is:
/usr/bin/spawn-fcgi
For example, our fastcgi program is/home/www/cgi-bin/fast.bin, and he's our own CGI program written and compiled in C or other languages.
Let him reside in the background with the following command, and bind to port 10001
Spawn-fcgi-a 127.0.0.1-p 10001-u freeworm-g freeworm-f/home/www/cgi-bin/fast.bin
Edit Virtual Host, add
Location/fast.bin {
Fastcgi_pass 127.0.0.1:10001;
Include/etc/nginx/fastcgi_params;
}
You can then access it through a link like this:
Http://www.nginx.com.cn/fast.bin
Reference Document: Http://wiki.codemongers.com/NginxFcgiExample
From Nginx Chinese web: http://www.nginx.com.cn/?p=349