1、登录系统后执行 vi /etc/yum.repos.d/nginx.repo 编辑nginx的yum源。从ngix官网复制相关内容粘贴后输入:wq保存并退出。
[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
2、执行yum install nginx -y 安装nginx。
3、执行systemctl start nginx启动nginx。执行systemctl status nginx查看状态
4、执行systemctl enable nginx设为开机启动。