Home >Operation and Maintenance >Nginx >Analysis of Nginx installation examples under CentOS

Analysis of Nginx installation examples under CentOS

PHPz
PHPzforward
2023-05-11 20:28:11973browse

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 to replace the os version: $releasever, for example, the centos version is 7, Replace it with 7)

Command:

Use vim to edit the nginx.repo file

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

Set the yum source of nginx:

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 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 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 again to confirm

5. Start | Stop | Restart nginx:

# 启动
systemctl start nginx.service

# 停止
systemctl stop nginx.service

# 重启
systemctl restart nginx.service

6. View all installation locations of nginx:

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

rpm -ql nginx

7. nginx configuration file:

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

The above is the detailed content of Analysis of Nginx installation examples under CentOS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete