centos8安装nginx时报错Status:404

centOS 8 安装nginx报错:

[root@xxx]# yum install nginx
CentOS Linux 8 - AppStream                                                                            6.3 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'appstream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 100.100.2.148)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

解决

1. 备份原有配置

cp /etc/yum.repos.d/CentOS-Linux-BaseOS.repo /etc/yum.repos.d/CentOS-Linux-BaseOS.repo1

cp /etc/yum.repos.d/CentOS-Linux-AppStream.repo /etc/yum.repos.d/CentOS-Linux-AppStream.repo1

2. 编辑配置文件

① 编辑CentOS-Linux-BaseOS.repo

vim /etc/yum.repos.d/CentOS-Linux-BaseOS.repo

此时进入了正常模式,然后按冒号键进入命令模式,执行以下命令:

%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g
%s/$releasever/$releasever-stream/g

保存退出:

:wq!

② 编辑CentOS-Linux-AppStream.repo

vim /etc/yum.repos.d/CentOS-Linux-AppStream.repo

此时进入了正常模式,然后按冒号键进入命令模式,执行以下命令:

%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g
%s/$releasever/$releasever-stream/g

保存退出:

:wq!

3. 构建缓存,更新yum源

yum makecache
yum update

4. 继续安装nginx:

sudo yum install nginx
Is this OK[Y/N]:   y

centos8安装nginx时报错Status:404_第1张图片

启动nginx服务

$ sudo systemctl enable nginx
$ sudo systemctl start nginx

检验nginx是否在运行:

$ sudo systemctl status nginx

默认80端口,浏览器打开访问:

centos8安装nginx时报错Status:404_第2张图片

你可能感兴趣的:(Linux,杂谈,nginx,linux,centos)