学无先后,达者为师

网站首页 编程语言 正文

centos8安装nginx时报错Status:404

作者:Pisces_224 更新时间: 2022-02-27 编程语言

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

在这里插入图片描述

启动nginx服务

$ sudo systemctl enable nginx
$ sudo systemctl start nginx

检验nginx是否在运行:

$ sudo systemctl status nginx

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

在这里插入图片描述

原文链接:https://blog.csdn.net/qq_36256590/article/details/122937744

栏目分类
最近更新