Home > OS >  Compile nginx fastcgi cross-compilation transplantation
Compile nginx fastcgi cross-compilation transplantation

Time:10-04

Unzip the package
The tar ZXVF nginx, version 1.8.1 -. Tar. Gz

The tar ZXVF pcre 8.35. Tar. Gz

The tar ZXVF zlib - 1.2.8. Tar. Gz

The tar ZXVF openssl - i.t ar 1.0.1. Gz

Add user
Groupadd -r nginx

Useradd - r - g nginx nginx

Compile the installation
CD/opt/software/nginx, version 1.8.1 -
./configure \
-- prefix=/opt/nginx \
- with - http_ssl_module \
- with - http_gzip_static_module \
- with - http_stub_status_module \
- with - http_realip_module \
- pid - path=/var/run/nginx pid \
- with - pcre=/opt/software/pcre - 8.35 \
- with - zlib=/opt/software/zlib - 1.2.8 \
- with - openssl=/opt/software/openssl - 1.0.1 I

Make

Make install & amp; & Echo OK

Start the nginx
Validity check
# check after each modification nginx configuration file

The/opt/nginx/sbin/nginx - t


Start the nginx
/opt/nginx/sbin/nginx

Reload nginx
/opt/nginx/sbin/nginx -s reload

A key installation script
To integrate the above steps and a script to compile the install nginx


Install spawn - fcgi:

L get spawn - fcgi compile the installation package, at http://redmine.lighttpd.net/projects/spawn-fcgi/wiki access to the latest version of the current,

L extract spawn - fcgi - X.X.X.T ar. Gz packages,

L into the unzipped directory, execute./configure,

L make & amp; Make install


L get fcgi compile the installation package, at http://www.fastcgi.com/drupal/node/5 to get the latest version of the current,

L extract fcgi - X.X.X.T ar. Gz packages,

L into the unzipped directory, execute./configure,

L make & amp; Make install

In/include/fcgio. H file add # include & lt; Cstdio> Through the installation, and then compile the

If prompt can not find the dynamic library, please in the LD_LIBRARY_PATH or/etc/ld. So, the conf add fcgi installation path, such as/usr/local/lib, and perform the ldconfig update,

# include "fcgi_stdio. H"

# include & lt; stdlib.h>



Int main (void)

{

int count=0;

While (FCGI_Accept () & gt;=0)

Printf (" content-type: text/HTML \ r \ n "

"The \ r \ n
"
"& lt; title> FastCGI Hello! "

"& lt; H1 & gt; FastCGI Hello!
"The Request number % d running on the host & lt; i> % s \ n ",

+ + count, getenv (" SERVER_NAME "));

return 0;

}


G + + compiler. The main CPP -o demo - lfcgi, and will be deployed to the demo/opt/nginx - 1.7.7/cgi - bin/directory

Through the spawn - fcgi start c/c + + write good fastcgi program:/opt/nginx 1.7.7/sbin/spawn 127.0.0.1 fcgi - a - p - 8081 - f/opt/nginx - 1.7.7/cgi - bin/demo

3.1.3. Nginx fastcgi configuration
About several nginx configuration file parsing, can refer to the nginx installation and the use of "http://www.cnblogs.com/skynet/p/4146083.html, in our nginx. Based on the conf fastcgi configuration below,



This nginx receives the request, http://localhost/demo.cgi will match to location=/demo. The cgi blocks, the request to the backend fastcgi application processing, the following as shown in: (note the number 80, because I asked 80 times)

CodePudding user response:

To move a brick, onlookers tutorial
  • Related