1.安装nginx依赖
sudo yum install yum-utils
2.创建yum存储库的nginx源文件
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
3.安装nginx
sudo yum install nginx -y

说明:-y 为忽略问询选项自动安装,若要接受步骤问询可不带本参数

4.设置nginx开机启动
sudo systemctl enable nginx.service
5.启动nginx
sudo systemctl start nginx.service
6.停止nginx
sudo systemctl stop nginx.service
7.重启nginx
sudo systemctl restart nginx.service

Oliver
1 声望1 粉丝

学会思考