文章目录
展开
1、先安装先决条件:yum-utils
sudo yum install yum-utils -y
2、设置yum repos
创建文件/etc/yum.repos.d/nginx.repo
sudo vi /etc/yum.repos.d/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 [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
默认情况下,安装稳定版(stable)nginx,如果要安装主线版本(mainline) nginx包,请运行以下命令:
sudo yum-config-manager --enable nginx-mainline
3、安装nginx
sudo yum install nginx -y
查看nginx版本
nginx -v
nginx version: nginx/1.16.0
3、启动 nginx
#启动 systemctl start nginx #检查状态 systemctl status nginx #设置自启动 systemctl enable nginx
到此,Nginx安装结束。