Nginx installation on linux and detailed explanation of configuration files

foreword

This article explains the installation of nginx on the Liunxi system and its configuration files in detail


提示:以下是本篇文章正文内容,下面案例可供参考

1. What is Nginx?

Nginx is a powerful high-performance web and reverse proxy service that also provides IMAP/POP3/SMTP services. In the case of high concurrent connections, Nginx can support responses up to 50,000 concurrent connections.
Nginx as a load balancing service: Nginx can directly support Rails and PHP programs to provide external services internally, and can also support external services as an HTTP proxy service.
Handle static files, index files, and auto-index; open file descriptor buffering.
Cache-free reverse proxy acceleration, simple load balancing and fault tolerance.
FastCGI, simple load balancing and fault tolerance.

2. Install Nginx on Linux

1. Download nginx

Nginx official website download
Baidu network disk extraction
Link: https://pan.baidu.com/s/13byiCMlbkg7AkeM8j8h54A
Extraction code: 99ea

2. Install

  1. Because Nginx is developed for C voice, install the dependent environment first
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
  1. Use wget to download Nginx, or upload the package downloaded by windows directly
//如果已经安装wget   则不需要执行此命令
yum install wget
// 使用wget下载稳定版 Nginx 
wget https://nginx.org/download/nginx-1.22.0.tar.gz
  1. unzip nginx
 tar -zxvf nginx-1.22.0.tar.gz
  1. Create a directory for installing Nginx
mkdir -p /soft/Nginx
  1. Enter the Nginx decompression directory and install Nginx
 cd nginx-1.22.0
//指定nginx安装到那个目录下
 ./configure --prefix=/soft/Nginx/
  1. After compiling and installing Nginx
make && make install
  1. Start nginx after the installation is complete
// 进入nginx  sbin目录
cd /soft/Nginx/sbin/
//启动
 ./nginx
  1. Visit the page, enter the ip address in the navigation bar
    insert image description here

3. Nginx common commands

//绝对路径启动
/soft/Nginx/sbin/./nginx 
//停止 进入sbin目录
./nginx -s stop
//绝对路径停止
/soft/Nginx/sbin/./nginx -s stop
//重启  进入sbin目录
./nginx -s reload
//查看Nginx进程
ps -ef | grep nginx

4. Detailed configuration file

1. Directory analysis:

conf: store configuration files
logs: store logs
html: store static resources, such as: js, html, css, etc.
sbin: start and close, etc.

2. Analysis of nginx.conf----deployment of static resources

insert image description here

2. nginx.conf analysis----reverse proxy

insert image description here

3. nginx.conf analysis ----- load balancing

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/packge/article/details/125082814