Nginx FastCGI C ++ development framework configuration instructions

Source: Internet
Author: User
Tags nginx server
Document directory
  • Preface
  • Development Framework
  • Nginx Installation
  • Nginx Configuration
  • Start and restart nginx
  • Spawn-fcgi
  • Fast-CGI Service Program Development
  • Test
Preface I have collected a lot of related articles on the Internet. The reason why I wrote this article was original is that most of the articles have detailed issues, and there are more PHP articles and less C ++ articles. Just a rough description of the installation steps, such as the nginx. conf format and each command parameter do not need to be further explored ~ About the development framework 1. The nginx server is only responsible for forwarding requests and forwarding requests to the FastCGI service program developed by itself. 2. spawn-fcgi is used to manage FastCGI applications. It is a subproject of Lighttpd. 3. the FastCGI Service Program receives the request and processes the request. Then, the nginx server is responsible for forwarding the returned results of the FastCGI service to the client. A URL: http: // 10.1.144.142: 8090/fcgi_test? The A = 1nginx application sees http: // 10.1.144.142: 8090/fcgi_test. According to the fcgi_test "location" field, the parameter section "A = 1" after the question mark is forwarded to the FastCGI service for processing. Therefore, the FastCGI service program sees "A = 1" nginx installation 1. nginx installation depends on the OpenSSL and PCRE libraries. Download three libraries: nginx-0.8.53, openssl-1.0.1c, pcre-8.31 decompress to the corresponding location, enter the nginx folder, configure needs to specify the path of the two dependent libraries, Blog1My_configure script in:
./configure --prefix=/usr/local/nginx \      --with-pcre=/home/nginx_software/pcre-8.31 \      --with-openssl=/home/nginx_software/openssl-1.0.1c \      --with-http_stub_status_module \      --with-http_ssl_module

Nginx installation directory:/usr/local/nginx, PCRE decompression path is/home/nginx_software/pcre-8.31

The installation procedure is as follows:
sh my_configuremake && make install

2. Install spawn-fcgi and install lighttpd-1.4.19

Enter the nginx installation directory/usr/local/nginx/to enter the conf directory, and open nginx. in the conf configuration file, the structure of the conf file is that the server listens to different ports. The server has the following location. Add the following code to the server:
location /fcgi_test {            fastcgi_pass 127.0.0.1:9000;            include fastcgi_params;        }
Requests of the/fcgi_test type are allocated to the FastCGI service program listening for 9000. Start and restart nginx 1. Start directly./nginx 2. Other operations: In the usr/local/nginx/sbin/directory./nginx-h, a line is displayed:
-s signal : send signal to a master process: stop, quit, reopen, reload 
./Restart nginx-s reopen. Spawn-fcgi pulls the FastCGI service program developed by itself, listens to port 9000, and then processes the request. Blog1Medium
/usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 25 -f /usr/local/nginx/myFastCGI/helloFastCGI -F 1000
-F parameter. If the actual measurement is incorrect, remove it. Fast-CGI service program development is a simple C ++ program development. When using a third-party library fast-CGI, you must specify the include and Lib directories in makefile. See Blog2Code framework similar to hello-fcgi in. Test the local call of curl "http: // 127.0.0.1: 8090/fcgi_test? A = 1 "in the client browser, type http: // 10.1.144.142: 8090/fcgi_test? A = 1 test succeeded: The nginx server I wrote listens to port 8090. The default port is not used. If port 80 is used, the port number can be left blank. The makefile shown in blog2 has an error in the actual make test. You can use the general makefile framework here: http://blog.csdn.net/dizuo/article/details/7989411targetto change the service name. Reference: 1. Blog1: Http://www.cnblogs.com/xiaouisme/archive/2012/08/01/2618398.html2. Blog2: Http://blog.csdn.net/yonghengkxh/article/details/8084460

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.