1.安装先决条件
yum install yum-utils
2.设置yum存储库和创建/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
3.默认情况用稳定版本的,使用主线nginx包,请运行以下命令:
yum-config-manager --enable nginx-mainline
4.安装nginx
yum install nginx -y
5.启动nginx和开机自启nginx设置
systemctl start nginx
systemctl enable nginx
6.查看安装的nginx 版本
nginx -v