Nginx study notes 01-Introduction and installation of Nginx

Nginx study notes 01-Introduction and installation of Nginx

Write in front

If you can click to read this article, then you may have heard of the name Nginx and want to start learning and mastering Nginx. Maybe you are a front-end programmer, and learning Nginx has become a hard requirement in your work.

No matter what the situation is, if you are initially exposed to Nginx Ying Xiaobai, then this series of articles may take you step by step to get started with Nginx. Not much nonsense, let's get started!

1. What is Nginx

First quote the official definition:

Nginx is an HTTP web server with asynchronous framework, and can also be used as a reverse proxy, load balancer, and HTTP cache. Nginx is free and open source software, released under the terms of a BSD-like license.

As an Nginx novice, you don't need to care about load balancing and reverse proxy. I will explain it in a later article. Here we only need to know the following two points:

  1. Nginx is a web server that supports HTTP service, we can use it to build our server
  2. Nginx is open source and free, we can use it with confidence

Knowing what Nginx is, we also need to understand some of its advantages:

  1. Support massive high concurrency
  2. Low memory consumption
  3. Free to use and commercial
  4. The file configuration is simple, which is very friendly to development and operation and maintenance students

The popularity of Nginx and its various advantages make it very necessary for us to learn and master it. For a novice, learning Nginx actually requires some basics. Before learning, we need to prepare:

  1. Basic Linux system knowledge, because most servers are deployed on Linux servers, the following Nginx tutorials are also carried out on Linux CentOS systems. Of course, you don't need to have a special in-depth mastery. You are familiar with Linux command line tools, and you can use vim, yum and other tools.
  2. A computer with Linux operating system can rent a cloud server or use a virtual machine with Linux operating system.

With the above conditions, let's start the installation of Nginx.

2. the initial installation of Nginx

When writing this article, I am using CentOS 7 on Linux . If your version is inconsistent with mine, some commands may be inconsistent. If you encounter problems, Baidu a lot.

Installing Nginx on CentOS is actually very convenient. We can install it with the help of yum, a package management tool. 1. execute the following commands to install some basic tools in Linux:

yum -y install gcc gcc-c++ autoconf pcre-devel make automake
yum -y install wget httpd-tools vim

When installing Nginx, it is recommended that you first open the Nginx official website ( ) to check the current version of Nginx, we do not need to install the latest version, just install the stable version:

From the figure, we can see that the current stable version of Nginx is 1.16.1 . At this time, we come to Linux and check what is the latest version of Nginx in the current yum package management tool. You can check it by executing the following command:

yum list | grep nginx

As you can see from the above figure, the latest Nginx version in the yum package management tool is 1.16.1, which is synchronized with the official website version. If the Nginx version we check here is too low or the Nginx version information is not found at all, then the following methods can be used to update the yum source:

  1. In the Linux system, execute the command:, cd/etc/yum.repos.dswitch the folder to the yum source configuration folder /etc/yum.repos.d

  2. Execute the command:, vim nginx.repocreate a new file and name it nginx.repo, then save all the following codes into the file, save and exit.

    name=nginx stable repo
    name=nginx mainline repo

Now that the Nginx version in the yum source has been updated, we only need to execute the following command to install Nginx very conveniently. The command is as follows:

yum -y install nginx

Wait for a while, Nginx is installed successfully, execute the command nginx -v, you can view the successfully installed version of Nginx

Write at the end

At this point, we have successfully installed Nginx. We hope that all students can follow the above steps in order to install Nginx successfully. If you encounter any problems or errors, I hope you will actively find information.

In the next blog, I will share with you the Nginx configuration file and how to modify the Nginx configuration file according to actual needs. Come on, everybody!