Test of nginx+fastcgi

Source: Internet
Author: User

Nginx + fastcgi configuration method One, Nginx installation & configuration1) apt-get Install Nginx
2) Modify the default file under/etc/nginx/sites-available

</pre><pre name= "code" class= "plain" > #设置首页root/usr/share/nginx/myweb;index index.html index.htm;# Modify Port Listen 8880 Default_server;listen [::]:8880 default_server ipv6only=on; #设置fastcgi程序入口location/mycgi.cgi {        Fastcgi_pass 127.0.0.1:9999; FASTCGI program monitoring port        #fastcgi_index mycgi.out;        Include Fastcgi_params;}
Second, the installation of FastCGI manager spawn-fcgi apt-get Install spawn-fcgi

Third, the installation of FCGI Library did not find the official website to download, some strange, temporary reference accessories.

1) Modify Include/fcgio.h file, append # include <cstdio>
2)./configure
3)./make Install
4) ldconfig/usr/local/lib (libfcgi.so default build path)

The example code of compiling CGI program is as follows:

#include <iostream> #include <fcgi_stdio.h> #include <stdlib.h> #include <sys/types.h># Include <unistd.h>int main (int argc, char** argv) {    int count = 0;    while (fcgi_accept () >= 0)    {        printf ("content-type:text/html\r\n\r\n");        printf ("<p> Hello FastCGI!  </p> ");        printf ("<br/> Request number = [%d]", ++count);        printf ("<br/> CGI PID:%d", getpid ());    }    return 0;}

Compile

g++ Mycgi.c-o mycgi.out-l/usr/local/lib-lfcgi

Five, start cgispawn-fcgi-a 127.0.0.1-p 9999-f/root/mycgi/mycgi.out-f 3
-f Specifies the number of CGI processes to start, and nginx polls the access
You can see the output of the CGI program by accessing http://server:8880.

Test of nginx+fastcgi

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.