Back end_ Server_ Nginx




Mainstream servers: nginx, Apache, Tomcat
Initial nginx, nginx architecture foundation, detailed explanation of HTTP module, reverse proxy and load balancing, nginx system layer performance optimization, in-depth use of ngixn and openresty from the source code perspective
The main application scenarios of nginx are as follows:
Back end_ Server_ Nginx
The appearance of nginx was as follows
The rapid growth of Internet data, globalization, performance improvement, offset Apache, a process can only serve one connection
Advantages of nginx:
High concurrency, high performance, good scalability (modular design, rich ecosystem), high reliability (can run for a long time without restart), hot deployment (upgrade nginx without stopping service), BSD license (open source, free)

The composition of nginx is as follows

  1. Nginx binary executable file: a file compiled by the source code of each module
  2. Nginx.conf : controls the behavior of nginx
  3. access.log Access log: record HTTP request information every day
  4. error.log Error log: location problem

Distribution of nginx:
Official Website Version: the odd version number is the main version, which is relatively unstable. The even number version number is the stable version, relatively stable
Official website commercial version, Alibaba’s Tengine, free version openresty and commercial version openresty

Edit nginx

Download nginx, introduce the directory. Configure, intermediate file introduction, compilation, installation

  1. Download the official website, copy the stable version connection, and $WGet in Linux…
  2. $tar -xzf nginx.1.16.1. tar.gz $CD nginx. 1.16.1
  3. Contents:
   CC: for compilation
CHANGES:nginx Features provided by each version : Russian version of changes
Conf: sample file (?)
Configure: generate intermediate files for compilation
Contrib: provides two scripts,
HTML: provides two standard HTML files, 50x. HTML and index.html
Man: help files
src:nginx Source code
   --With is not compiled to nginx by default
   --Without is compiled to ngixn by default

4. Specify the installation directory. / configure — prefix = / home / soapeye / nginx
C compiler CC is not found, error of installing nginx: Yum – y install WGet
5. Nginx configuration syntax

1. Configuration file is composed of instruction and instruction block
2. Each instruction ends with a semicolon, and the instruction and parameter are separated by a space character
3. Instruction block organizes multiple instructions with {} braces
4. Include statement allows multiple configuration files to be combined to improve maintainability
5. Use $to match usage variables
6. Use ා symbol to add notes to improve readability
7. The parameters of some instructions support regular expressions
Configuration parameters: ms, MS, s, m, h, D, W, m, y 
k/K m/M g/G
HTTP configuration instruction block: server, HTTP, location, upstream

Command line: overload configuration file, hot deployment, cutting log file

Nginx command line:
Format: nginx - s reload
Help: -? - H
#Modify the configuration file and reload it
$./nginx -s reload
#Hot deployment