1.安装 yum-utils
sudo yum install yum-utils
2. 创建nginx.repo
touch /etc/yum.repos.d/nginx.repo
3. vi /etc/yum.repos.d/nginx.repo 打开编辑nginx.repo,添加如下内容
[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
注:cat /etc/yum.repos.d/nginx.repo 查看添加的内容
4.安装nginx
sudo yum install nginx