Teach you how to quickly install Nginx in CentOS7

Teach you how to quickly install Nginx in CentOS7

1. Overview

Nginx is an indispensable tool when we develop Java projects. Most of the time, it is used as a reverse proxy backend server to achieve load balancing and solve high concurrency.

Most of the time, Nginx installation and configuration is done by operation and maintenance personnel, but in some companies without operation and maintenance positions, developers are still needed to do this work.

Today we will explain how to quickly install Nginx on CentOS7 system without going into details.

2. Download the Nginx installation package

1) Go to the Nginx official website (https://nginx.org/) and click the download link

download

Screenshot from the official website

2) In the Stable version, download the latest version

Download 2

Screenshot from the official website

3. Install dependency packages

In CentOS7 command line mode, enter the following commands in sequence to install the required dependency packages

yum install -y gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

insert image description here
insert image description here

4. Copy the Nginx installation package to the CentOS7 system and decompress it

There are many ways to copy the installation package to the CentOS7 system. You can use the Xshell tool to connect to the CentOS7 system and use the rz command to upload it, or you can use Xftp or other tools to upload it.

Here we put the Nginx installation package in the /home directory.

Enter the /home directory

Enter the tar -zxvf nginx-1.20.1.tar.gz command to decompress the installation package.

insert image description here

5. Configure Nginx

Enter the unzipped Nginx folder, # cd nginx-1.20.1

Enter the configuration command:

./configure
--prefix=/usr/local/nginx
--pid-path=/var/local/nginx/nginx.pid
--lock-path=/var/local/nginx/nginx.lock
--error-log-path=/var/local/nginx/error.log
–http-log-path=/var/local/nginx/access.log
–with-http_gzip_static_module
–http-client-body-temp-path=/var/local/nginx/client
–http-proxy-temp-path=/var/local/nginx/proxy
–http-fastcgi-temp-path=/var/local/nginx/fastcgi
–http-uwsgi-temp-path=/var/local/nginx/uwsgi
–http-scgi-temp-path=/var/local/nginx/scgi

insert image description here
insert image description here

6. Compile and install

Compile, enter the command: # make

After installation and compilation is complete, enter the command: # make install

insert image description here
insert image description here

7. Start Nginx

Enter the Nginx directory: # cd /usr/local/nginx/sbin

Enter the startup command: # ./nginx

At this time, use the browser to access the IP address of the CentOS7 server, and you can see the homepage of Nginx.

insert image description here

8. Common commands of Nginx

Nginx forced stop command: # ./nginx -s stop

Nginx graceful stop command: # ./nginx -s quit // Graceful stop means waiting until the last interaction is completed before stopping.

Nginx checks the configuration file for errors: # ./nginx -t

Nginx reload command: # ./nginx -s reload

Check the Nginx version: # ./nginx -v

View the detailed version of Nginx: # ./nginx -V

9. Overview

The installation of Nginx is relatively simple. Later, I will introduce other uses of Nginx. Everyone is welcome to communicate more.

This is the end of this article about how to quickly install Nginx in CentOS7. For more information about how to install Nginx in CentOS7, 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:
  • Solve the problem of "Welcome to nginx on Fedora!" after installing nginx on Centos7, and there is no default.conf file in the conf.d directory
  • How to install Nginx in CentOS7 and configure automatic startup
  • Tutorial on installing lnmp using yum on centos7 (linux+nginx+php7.1+mysql5.7)
  • How to install Nginx using yum in CentOS7
  • How to install Nginx in CentOS7.2
  • How to Install Nextcloud with Nginx and PHP7-FPM in CentOS7
  • Two methods of installing nginx on centos7

<<:  CSS controls the spacing between words through the letter-spacing property

>>:  HTML+CSS+JS to implement the Don't Step on the Whiteboard game

Recommend

JavaScript array merging case study

Method 1: var a = [1,2,3]; var b=[4,5] a = a.conc...

MySQL 8.0.16 installation and configuration tutorial under Windows 10

This article shares with you the graphic tutorial...

A quick guide to MySQL indexes

The establishment of MySQL index is very importan...

Linux sar command usage and code example analysis

1. CPU utilization sar -p (view all day) sar -u 1...

MySQL database transaction example tutorial

Table of contents 1. What is a transaction? 2. Th...

MySQL database backup and recovery implementation code

Database backup #grammar: # mysqldump -h server-u...

Detailed explanation of docker command to backup linux system

tar backup system sudo tar cvpzf backup.tgz --exc...

Solve the problem of the container showing Exited (0) after docker run

I made a Dockerfile for openresty on centos7 and ...

How to use localStorage in JavaScript

If you are a developer looking to get into the wo...

Nexus uses nginx proxy to support HTTPS protocol

background All company websites need to support t...

Detailed explanation of how to use join to optimize SQL in MySQL

0. Prepare relevant tables for the following test...

Ubuntu View and modify mysql login name and password, install phpmyadmin

After installing MySQL, enter mysql -u root -p in...