0%

CentOS7使用yum安装Nginx

首先安装yum-utils

sudo yum install yum-utils

创建/etc/yum.repos.d/nginx.repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[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

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

repo默认使用stable版本,如果想使用mainline开发版本

sudo yum-config-manager --enable nginx-mainline

安装nginx

sudo yum install nginx

如果有指纹效验 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 接受它就好了

服务管理

启动
systemctl start nginx.service
停止
systemctl stop nginx.service
开机自起
systemctl enable nginx.service
取消开机自起
systemctl disable nginx.service

http://nginx.org/en/linux_packages.html#RHEL-CentOS