安装必备组件:
sudo yum install yum-utils
要设置 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
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=trueb
备份/etc/nginx 目录
cd /etc
cp -r nginx nginx-backup
卸载当前nginx
sudo yum remove nginx
默认情况下,使用稳定 nginx 包的存储库。如果您想使用主线 nginx (最新版本)包,请运行以下命令:
sudo yum-config-manager --enable nginx-mainline
要安装 nginx,请运行以下命令:
sudo yum install nginx
恢复nginx.conf:
将/etc/nginx-backup/nginx.conf 文件 替换到 /etc/nginx/nginx.conf中
启动nginx:
sudo systemctl start nginx
Comments