How to quickly install Nginx in Linux

How to quickly install Nginx in Linux

What is nginx

Nginx is a high-performance http server/reverse proxy server and email (IMAP/POP3) proxy server. Developed by Russian programmer Igor Sysoev, official tests show that nginx can support 50,000 concurrent connections, and its CPU, memory and other resource consumption is very low, and it runs very stably.

Application Scenario

http server. Nginx is an http service that can provide http services independently. Can be used as a static web server.

Virtual hosts. It is possible to virtualize multiple websites on one server. For example, a virtual host used by a personal website.

Reverse proxy, load balancing. When the website traffic reaches a certain level and a single server cannot meet the user's requests, multiple server clusters are needed and nginx can be used as a reverse proxy. In addition, multiple servers can share the load evenly, and there will be no situation where a server is idle due to downtime due to high load.

1. Download the required dependencies

yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel

2. Download the nginx compressed package

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

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-xneCUtIV-1631454669944) (G:\Typora#Nginx学习笔记.asserts\image-20210811230957878.png)]

3. Unzip, usually unzip to the /usr/local directory

tar zxvf nginx-1.16.1.tar.gz

4. Compile and install

Enter the unzipped directory ( the path is critical )

cd /usr/local/nginx-1.16.1

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-2HXdBiMe-1631454669948) (G:\Typora#Nginx学习笔记.asserts\image-20210811231412631.png)]

Use the configure command to check the installation environment

 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

–prefix specifies the installation directory of nginx. The default path is /usr/local/nginx.

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-Aipwxfja-1631454669950) (G:\Typora#Nginx学习笔记.asserts\image-20210811231926065.png)]

Compile using the make command

make

Now check the directory and find Makefile and objs

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-P6x3B8WO-1631454669952) (G:\Typora#Nginx学习笔记.asserts\image-20210811232350735.png)]

Install the compiled program

make install

Go to the installation directory to check whether the installation is complete

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-HOwy356W-1631454669953) (G:\Typora#Nginx学习笔记.asserts\image-20210811233029066.png)]

Installation Completed!

5. Start nginx

Enter the /usr/local/nginx/sbin directory and see the nginx executable file, as shown above

./nginx 

nginx started successfully!

Go to the page to visit and see that the default listening port is 80.

Just access the ip where nginx is located.

[External link image transfer failed. The source site may have an anti-hotlink mechanism. It is recommended to save the image and upload it directly (img-9VKIUoKA-1631454669954) (G:\Typora\Nginx study notes.asserts\image-20210912214825167.png)]

Note: If the previously specified installation directory is not /usr/local/nginx, a file missing error may be reported at startup. Follow the prompts to create the corresponding files.

Extensions:

./configure is the first step of source code installation. It configures the software to be installed and checks whether the installation environment has dependencies on the software. For example, it checks whether gcc is installed and generates makefiles. You can use make and make install to compile and install the program. You can add parameters such as –with, –enable, –without, –disable, etc. to control the compilation.

Make reads the makefile file, which is usually used to compile the makefile file when installing the program through the source code package.

make install is to install the compiled program

make clean deletes some temporary files (if executed here, Makefile and objs will be deleted)

Summarize

This is the end of this article on how to quickly install Nginx in Linux. For more information about installing Nginx in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed steps to install Nginx on Linux
  • Correct steps to install Nginx in Linux
  • Tutorial on installing nginx in Linux environment

<<:  WEB Chinese Font Application Guide

>>:  Detailed explanation of Vue lazyload picture lazy loading example

Recommend

MySQL data analysis storage engine example explanation

Table of contents 1. Introduce cases 2. View the ...

How to write high-quality JavaScript code

Table of contents 1. Easy to read code 1. Unified...

The difference between HTML name id and class_PowerNode Java Academy

name Specify a name for the tag. Format <input...

A magical MySQL deadlock troubleshooting record

background Speaking of MySQL deadlock, I have wri...

React implements dynamic pop-up window component

When we write some UI components, if we don't...

js to achieve drag and drop sorting details

Table of contents 1. Introduction 2. Implementati...

Discuss the application of mixin in Vue

Mixins provide a very flexible way to distribute ...

MySQL 5.7.17 winx64 installation and configuration graphic tutorial

I summarized the previous notes on installing MyS...

In-depth explanation of special permissions SUID, SGID and SBIT in Linux

Preface For the permissions of files or directori...

W3C Tutorial (15): W3C SMIL Activities

SMIL adds support for timing and media synchroniz...

CentOS 7 configuration Tomcat9+MySQL solution

Configure Tomcat First install Tomcat Installing ...

Detailed explanation of the JavaScript timer principle

Table of contents 1. setTimeout() timer 2. Stop t...