How to install Nginx in CentOS

How to install Nginx in CentOS

Official documentation: https://nginx.org/en/linux_packages.html#RHEL-CentOS

Installation environment: Linux server CentOS 7.3, Root privileges

1. Install the prerequisites:

sudo yum install yum-utils

2. To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

(Note to replace the OS version: $releasever, if the centos version is 7, replace it with 7)

Order:

Edit the nginx.repo file using vim

vim /etc/yum.repos.d/nginx.repo

Set up the Nginx yum source:

Paste the following content into the nginx.repo file

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

Enter the vim command: wq to save and exit

3.To install nginx, run the following command:

sudo yum install nginx
Enter y to confirm the installation.

4. When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

Finally, the fingerprint will be output. If it matches the red part above, enter y to confirm.

5. Start | Stop | Restart Nginx:

# Start systemctl start nginx.service

# Stop systemctl stop nginx.service

# Restart systemctl restart nginx.service

6. View all Nginx installation locations:

rpm is the rpm package management tool for Linux. -q stands for query mode, and -l stands for return list.

rpm -ql nginx

7. Nginx configuration file:

/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf

Summarize

The above is the method of installing Nginx under CentOS introduced by the editor. I hope it will be helpful to everyone!

You may also be interested in:
  • 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 on centos6.5 server and set up services and start it automatically
  • Installation tutorial of nginx1.12.1 under centos6.4
  • How to install Nginx using yum in CentOS 7
  • How to Install Nextcloud with Nginx and PHP7-FPM in CentOS7
  • Two methods of installing nginx on centos7
  • Install and configure Nginx on CentOS 7
  • Detailed tutorial on installing Nginx 1.10.2 on CentOS 7.2

<<:  Detailed explanation of 4 common data sources in Spark SQL

>>:  An example of how Vue implements four-level navigation and verification code

Recommend

A very detailed tutorial on installing rocketmq under Docker Desktop

Install Docker Desktop Download address: Docker D...

innodb_flush_method value method (example explanation)

Several typical values ​​of innodb_flush_method f...

64-bit CentOs7 source code installation mysql-5.6.35 process sharing

First install the dependent packages to avoid pro...

Solve the problem of installing Theano on Ubuntu 19

Solution: Directly in the directory where you dow...

Summary of Mathematical Symbols in Unicode

There are many special symbols used in mathematic...

WeChat applet realizes linkage menu

Recently, in order to realize the course design, ...

Let's talk about MySQL joint query in detail

Table of contents Union query 1. Query the ID and...

A complete guide to Linux environment variable configuration

Linux environment variable configuration When cus...

Detailed steps to configure MySQL remote connection under Alibaba Cloud

Preface As we all know, by default, the MySQL ins...

Implementation of CSS scroll bar style settings

webkit scrollbar style reset 1. The scrollbar con...

HTML multi-header table code

1. Multi-header table code Copy code The code is a...

CSS3 uses transform to create a moving 2D clock

Now that we have finished the transform course, l...

js canvas realizes circular water animation

This article example shares the specific code of ...