Method to install Nginx under CentOS

  • 2020-05-24 06:53:32
  • OfStack

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

Installation environment: Linux server CentOS 7.3, Root permissions

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 replace OS version: $releasever, if centos version is 7, replace it with 7)


Edit the nginx.repo file using vim

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

Set Nginx's yum source:

Paste the following into the nginx.repo file

name=nginx stable repo

Enter the vim command :wq save and exit

3. To install nginx, run the following command:

sudo yum install nginx
You will enter y to confirm the installation

4. When prompted to accept the GPG key verify that the fingerprint matches B FD6B D8BC64 1079 A5 BD82 7BD9 BF62, and if so, accept it.

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

5. Start |, stop | and restart Nginx:

#  Start the 
systemctl start nginx.service

#  stop 
systemctl stop nginx.service

#  restart 
systemctl restart nginx.service

6. Check all installation locations of Nginx:

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:



The above is the site to introduce you CentOS under the installation of Nginx method, I hope to help you!

Related articles: