Linux under nginx compilation installation tutorial and compilation parameters details

  • 2020-05-10 23:13:39
  • OfStack

1. Necessary software preparation
1. Install pcre

To support rewrite functionality, we need to install pcre

# yum install pcre* // If you have already installed it, please skip this 1 step 

2. Install openssl

You need ssl support. If you don't need ssl support, skip this step

# yum install openssl*

3. Installation of gzip class library

yum install zlib zlib-devel

4. Install wget

Download nginx for use, skip this step if you already have it installed

# yum install wget

2. Install nginx

1. Download

wget http://nginx.org/download/nginx-1.7.0.tar.gz

2. Unzip

tar -zxvf nginx-1.7.0.tar.gz

3. Compile and install
Execute the following command:

# cd nginx-1.7.0
# ./configure --prefix=/usr/local/nginx-1.7.0 \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre

Copyright © 2014 all rights reserved. All rights reserved. Copyright © 2014 all rights reserved
-- with-http_ssl_module: https is supported
If you want to know more about spdy of google, please refer to baidu spdy. ssl must be supported by with-http_spdy_module
To support the rewrite rewrite function, pcre must be developed

Finally, the output is as follows, indicating configure OK.


checking for zlib library ... found
 creating objs/Makefile
Configuration summary
 + using system PCRE library
 + using system OpenSSL library
 + md5: using OpenSSL library
 + sha1: using OpenSSL library
 + using system zlib library
nginx path prefix: "/usr/local/nginx-1.7.0"
 nginx binary file: "/usr/local/nginx-1.7.0/sbin/nginx"
 nginx configuration prefix: "/usr/local/nginx-1.7.0/conf"
 nginx configuration file: "/usr/local/nginx-1.7.0/conf/nginx.conf"
 nginx pid file: "/usr/local/nginx-1.7.0/logs/nginx.pid"
 nginx error log file: "/usr/local/nginx-1.7.0/logs/error.log"
 nginx http access log file: "/usr/local/nginx-1.7.0/logs/access.log"
 nginx http client request body temporary files: "client_body_temp"
 nginx http proxy temporary files: "proxy_temp"
 nginx http fastcgi temporary files: "fastcgi_temp"
 nginx http uwsgi temporary files: "uwsgi_temp"
 nginx http scgi temporary files: "scgi_temp"
# make // Make sure your server is installed make , if not installed, please execute yum install make

# make install

3. Start, close and reset nginx

Launch: directly execute the following command, and nginx will start without changing any configuration files. Please refer to the following article for the configuration of nginx multi-domain virtual host.

/usr/local/nginx-1.7.0/sbin/nginx

Try access: directly use the curl command to read the web information

[root@ns conf]
# curl -s http://localhost | grep nginx.com
nginx.com.

Close:
/usr/local/nginx-1.7.0/sbin/nginx -s stop

Reset: when you modify the configuration file, you only need reload below
/usr/local/nginx-1.7.0/sbin/nginx -s reload

That's the end of the whole nginx installation.

4. Explanation of nginx compilation parameters


 � prefix=  Point to the installation directory 
 � sbin-path  Point to (execute) the program file ( nginx ) 
 � conf-path=  Point to the configuration file ( nginx.conf ) 
 � error-log-path=  Point to the error log directory 
 � pid-path=  Point to the pid File ( nginx.pid ) 
 � lock-path=  Point to the lock File ( nginx.lock The installation file is locked to prevent the installation file from being used by others or your own operation. 
 � user=  Specifies a non-privileged user for the program to run 
 � group=  Specifies a non-privileged user group for the program to run 
 � builddir=  Point to compiled directory 
 � with-rtsig_module  To enable the rtsig Module support (real-time signal) 
 � with-select_module  To enable the select Module support ( 1 A polling mode , Not recommended for use in high-load environments without-select_module
 � with-poll_module  To enable the poll Module support (function with select The same with select Same property, is 1 A polling mode , Not recommended for use in high-load environments) 
 � with-file-aio  To enable the file aio Support ( 1 Kind of APL File transfer format 
 � with-ipv6  To enable the ipv6 support 
 � with-http_ssl_module  To enable the ngx_http_ssl_module To make supportive of https Request, installed openssl ) 
 � with-http_realip_module  To enable the ngx_http_realip_module Support (this module allows you to change the client from the request header IP Address value, default is off) 
 � with-http_addition_module  To enable the ngx_http_addition_module Support (as 1 Three output filters, support incomplete buffering, partial response to requests) 
 � with-http_xslt_module  To enable the ngx_http_xslt_module Support for (filtering transformations XML Request) 
 � with-http_image_filter_module  To enable the ngx_http_image_filter_module Support (transmission) JPEG/GIF/PNG  The image 1 Is not enabled by default. gd Library to use) 
 � with-http_geoip_module  To enable the ngx_http_geoip_module Support (the module is created based on and MaxMind GeoIP2 Base file matching client IP Address of the ngx_http_geoip_module Variables) 
 � with-http_sub_module  To enable the ngx_http_sub_module Supported (allowed) 1 Some other text substitution nginx In the response 1 Some text) 
 � with-http_dav_module  To enable the ngx_http_dav_module Support (increase PUT,DELETE,MKCOL : create a collection ,COPY and MOVE Method) is turned off by default and needs to be compiled and turned on 
 � with-http_flv_module  To enable the ngx_http_flv_module Support (provides time-based offset files for seeking memory usage) 
 � with-http_gzip_static_module  To enable the ngx_http_gzip_static_module Support (online real-time compression of output data stream) 
 � with-http_random_index_module  To enable the ngx_http_random_index_module Support (random selection from directory 1 Directory index) 
 � with-http_secure_link_module  To enable the ngx_http_secure_link_module Support (calculate and check the security links required for the requirements) 
 � with-http_degradation_module   To enable the ngx_http_degradation_module Support (allows you to return when out of memory 204 or 444 Code) 
 � with-http_stub_status_module  To enable the ngx_http_stub_status_module Support (get nginx Working status since last startup) 
 � without-http_charset_module  disable ngx_http_charset_module Support (recoding) web Page, but only 1 The directions are from the server to the client, and only 1 Byte encoding can be recoded) 
 � without-http_gzip_module  disable ngx_http_gzip_module Support (the same as the module -with-http_gzip_static_module function 1 Sample) 
 � without-http_ssi_module  disable ngx_http_ssi_module Support (this module provides 1 The input processing server contains files ( SSI ) filters are currently supported SSI The list of commands is incomplete.) 
 � without-http_userid_module  disable ngx_http_userid_module Support (this module is used to handle subsequent requests to determine the client cookies ) 
 � without-http_access_module  disable ngx_http_access_module Support (this module provides 1 Simple host-based access control. allow / Rejected based on ip Address) 
 � without-http_auth_basic_module disable ngx_http_auth_basic_module The module is based on the user name and password that can be used http Basic authentication methods to protect your site or parts of it) 
 � without-http_autoindex_module  disable disable ngx_http_autoindex_module Support (this module is used to automatically generate directory lists only in ngx_http_index_module The module makes a request when the index file is not found. 
 � without-http_geo_module  disable ngx_http_geo_module Support (create 1 A variable whose value depends on the client IP Address) 
 � without-http_map_module  disable ngx_http_map_module Support (using arbitrary keys / Value pair setting configuration variable) 
 � without-http_split_clients_module  disable ngx_http_split_clients_module Support (this module is used to partition users based on certain conditions. Conditions such as: ip Address, header, cookies Etc.) 
 � without-http_referer_module  disable disable ngx_http_referer_module Support (this module is used to filter requests and reject headers Referer Request with incorrect value) 
 � without-http_rewrite_module  disable ngx_http_rewrite_module Support (this module allows you to change using regular expressions URI , and turn and select the configuration according to the variables. If the server Level to set this option, then they will be in  location Before. If the location There are more into 1 Step rewrite rule, location Some of the rules will still be enforced. If the URI Rewrite because location Part of the rule, then  location Parts will be executed again as new URI .   This loop will execute 10 Times, then Nginx Returns the 1 a 500 Error.) 
 � without-http_proxy_module  disable ngx_http_proxy_module Support (for proxy servers) 
 � without-http_fastcgi_module  disable ngx_http_fastcgi_module Support (this module allows Nginx  with FastCGI  Processes interact and are controlled by passing parameters FastCGI  Process work.   ) FastCGI1 Three resident common gateway interfaces. 
 � without-http_uwsgi_module  disable ngx_http_uwsgi_module Support (this module is used for medical purposes uwsgi Agreement, uWSGI Server related) 
 � without-http_scgi_module  disable ngx_http_scgi_module Support (this module is used to enable SCGI Agreement support, SCGI Agreement is CGI Protocol replacement. It is a 1 Applications and HTTP Service interface standards. It is somewhat like FastCGI But his design   Easier to implement.) 
 � without-http_memcached_module  disable ngx_http_memcached_module Support (this module is used to provide simple caching to improve system efficiency) 
-without-http_limit_zone_module  disable ngx_http_limit_zone_module Support (this module can control the number of concurrent connections for sessions based on conditions) 
 � without-http_limit_req_module  disable ngx_http_limit_req_module Support (this module allows you to 1 Limit the number of requests to three addresses 1 A given session or 1 Specific events) 
 � without-http_empty_gif_module  disable ngx_http_empty_gif_module Support (the module is resident in memory 1 a 1*1 The transparent GIF Image, can be called very quickly) 
 � without-http_browser_module  disable ngx_http_browser_module Support (this module is used to create values that depend on the request header. If the browser is modern  , $modern_browser Is equal to the modern_browser_value Instruction assigned value; Such as   If the browser is old , $ancient_browser Is equal to the  ancient_browser_value The value assigned by the instruction; If the browser is  MSIE , then  $msie Is equal to the 1 ) 
 � without-http_upstream_ip_hash_module  disable ngx_http_upstream_ip_hash_module Support (this module is used for simple load balancing) 
 � with-http_perl_module  To enable the ngx_http_perl_module Support (the module makes nginx Can be used directly perl Or through ssi call perl ) 
 � with-perl_modules_path=  set perl The module path 
 � with-perl=  set perl Library file path 
 � http-log-path=  set access log The path 
 � http-client-body-temp-path=  set http The client requests a temporary file path 
 � http-proxy-temp-path=  set http Proxy temporary file path 
 � http-fastcgi-temp-path=  set http fastcgi Temporary file path 
 � http-uwsgi-temp-path=  set http uwsgi Temporary file path 
 � http-scgi-temp-path=  set http scgi Temporary file path 
-without-http  disable http server function 
 � without-http-cache  disable http cache function 
 � with-mail  To enable the POP3/IMAP4/SMTP Agent module support 
 � with-mail_ssl_module  To enable the ngx_mail_ssl_module support 
 � without-mail_pop3_module  disable pop3 Protocol ( POP3 That is, of the post office agreement 3 A version , It is the protocol that governs how a personal computer connects to a mail server over the Internet to send and receive mail. Is the first Internet E-mail 1 Two offline protocol flags   quasi ,POP3 The protocol allows users to store mail from the server to the localhost , At the same time, delete or save mail on the mail server based on client actions. POP3 Agreement is TCP/IP In the family of agreements 1 Mainly used for   Support for using client to remotely manage email on server) 
 � without-mail_imap_module  disable imap Protocol ( 1 Type of mail access protocol. Its main function is that the mail client can get the information of the mail from the mail server, download the mail and so on through this protocol. IMAP Protocol runs in TCP/IP On top of the agreement,   The port used is 143 . It has to do with POP3 The main difference of the protocol is that instead of downloading all the mail, users can directly operate the mail on the server through the client. 
 � without-mail_smtp_module  disable smtp Protocol ( SMTP The simple message transfer protocol , It is a 1 Group a rule used to send messages from a source address to a destination address that controls how the message is routed. SMTP Agreement belongs to TCP/IP The protocol family, which helps each computer find the next letter when sending or transferring it 1 Three destinations.) 
 � with-google_perftools_module  To enable the ngx_google_perftools_module Support (for debugging, profiling performance bottlenecks) 
 � with-cpp_test_module  To enable the ngx_cpp_test_module support 
 � add-module=  Enable external module support 
 � with-cc=  Point to the C Compiler path 
 � with-cpp=  Point to the C Pretreatment path 
 � with-cc-opt=  Set up the C Compiler parameters ( PCRE You need to specify the pool with-cc-opt= " -I /usr/local/include "If used select() The function needs to increase the number of file descriptors at the same time with-cc- opt= " -D FD_SETSIZE=2048 "Specify. 
 � with-ld-opt=  Set the connection file parameters. ( PCRE You need to specify the pool with-ld-opt= " -L /usr/local/lib "). 
 � with-cpu-opt=  Specify compiled CPU , the available value is : pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
 � without-pcre  disable pcre library 
 � with-pcre  To enable the pcre library 
 � with-pcre=  Point to the pcre Library directory 
 � with-pcre-opt=  At compile time pcre The library sets additional parameters 
 � with-md5=  Point to the md5 Library file directory (message digest algorithm) 5 Version to provide message integrity protection) 
 � with-md5-opt=  At compile time md5 The library sets additional parameters 
 � with-md5-asm  use md5 Assembler source 
 � with-sha1=  Point to the sha1 Library directory (digital signature algorithm, mainly used for digital signature) 
 � with-sha1-opt=  At compile time sha1 The library sets additional parameters 
 � with-sha1-asm  use sha1 Assembler source 
 � with-zlib=  Point to the zlib The library catalog 
 � with-zlib-opt=  At compile time zlib Set additional parameters 
 � with-zlib-asm=  For the specified CPU use zlib Assembly source optimization, CPU A type of pentium, pentiumpro
 � with-libatomic  Provides for the implementation of atomic memory update operations 1 An architecture 
 � with-libatomic=  Point to the libatomic_ops The installation directory 
 � with-openssl=  Point to the openssl The installation directory 
 � with-openssl-opt  At compile time openssl Set additional parameters 
 � with-debug  To enable the debug The log 


Related articles: