Testing Nginx + FastCgi

Source: Internet
Author: User

Testing Nginx + FastCgi
Nginx + Fastcgi configuration method1. install and configure nginx1) apt-get install nginx
2) modify the default file under/etc/nginx/sites-available


 
 
# Set the homepage root/usr/share/nginx/myweb; index index.html index.htm; # modify the port listen 8880 default_server; listen [::]: 8880 default_server defaults 6only = on; # Set the fastcgi program entry location/mycgi. cgi {fastcgi_pass 127.0.0.1: 9999;-> port listened by the fastcgi Program # fastcgi_index mycgi. out; include fastcgi_params ;}
Ii. install apt-get install spawn-fcgi on the fastcgi Manager

3. The fcgi library cannot be downloaded from the official website. It is strange to see the attachment for temporary reference.

1) modify the include/fcgio. h file and append # include
2)./configure
3)./make install
4) ldconfig/usr/local/lib (default path generated by libfcgi. so)

4. Compile cgi program example Code as follows:

 

#include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       int main(int argc, char** argv){    int count = 0;    while( FCGI_Accept() >= 0 )    {        printf( "Content-type:text/html\r\n\r\n" );        printf( "
       

Hello FastCGI ! " ); printf( " Request number = [%d]", ++count ); printf( " CGI PID: %d ", getpid() ); } return 0;}

 

Compile

G ++ mycgi. c-o mycgi. out-L/usr/local/lib-lfcgi

V. Start cgispawn-fcgi-a 127.0.0.1-p 9999-f/root/mycgi. out-F 3
-F indicates the number of cgi processes started. nginx will poll the access
Access http: // server: 8880 to view the cgi program output.

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.