在CentOS 8中,使用yum时出现错误,镜像列表中没有url,类似如下:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

原因
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org

解决方法

如果你仍然需要运行CentOS 8,你可以在/etc/yum.repos.d中更新一下源。使用vault.centos.org代替mirror.centos.org。

# sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
# sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*

本质上是用仍在运行的URL替换之前的URL。这一段时间内应该可以解决这个问题。

在Centos 8系统上,Nginx有无法启动,如下问题解决如下

nginx: error while loading shared libraries: libluajit-5.1.so.2:
cannot open shared object file: No such file or directory

yum -y install lua*

nginx: error while loading shared libraries: libgd.so.3:
cannot open shared object file: No such file or directory
执行命令后,libgd.so.2就有了!

# yum install gd gd-devel -y

至此,已经OK

# nginx -t
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test is successful