1、linux中没有默认安装的gcc,通过yum发现没有可用软件包gcc
原因:这个系统没有注册到Red Hat订阅管理。你可以使用订阅管理器来注册,说白了就是要收费,不给钱不让用。。。。
2、查看系统版本:
百度red hat官方的rhel操作系统版本号与内核版本号的对应关系----CentOS 7
3、解决办法:
百度了很多,也试验了不少 ,教程都很乱。最后还是成功了,所以必须写下来。
不多抱怨,上干货!!!
在这非常感谢https://blog.csdn.net/jianm_liu/article/details/78316690 这篇文章的作者,代码可以从这边复制!!
更换CentOS的yum源,使用163的源(此方式要确定服务器能上网)
1、看看原来的yum都有什么
2、备份原yum,毕竟随意删除不是好习惯,万一这个方法不成功呢。。。
3、删除red hat yum源
4、再执行A步骤,看看是否删除了,不看也行
5、去http://mirrors.163.com/centos/7/os/x86_64/Packages/下载如下文件,至于放到哪自己记住就行
也可以直接命令下载 wget http://…….
6、安装新的yum 包
(1)
(2)
(3)
(4)
(5)
这里做点着重介绍。。。重点。。。。(包括出现的错误)
- 相互依赖的包要一起安装(上边第五步!)
- 有教程上没有说要下划红色箭头的那俩rpm,如果不安装的话会出现下边的问题。提示你要下载那俩!
3、--force --nodeps 的使用(自己百度为什么)
7、现在的yum查看
8、将CentOS的yum源更新到red hat中
下载地址:http://mirrors.163.com/.help/centos.html,
编辑文件内容 把版本号$releasever改为7,保存文件名为CentOS7-Base-163.repo,路径什么的对应好自己的。
然后把它放到/etc/yum.repos.d/下(mv也好 通过Xftp放也好)
-
# CentOS-Base.repo
-
#
-
# The mirror system uses the connecting IP address of the client and the
-
# update status of each mirror to pick mirrors that are updated to and
-
# geographically close to the client. You should use this for CentOS updates
-
# unless you are manually picking other mirrors.
-
#
-
# If the mirrorlist= does not work for you, as a fall back you can try the
-
# remarked out baseurl= line instead.
-
#
-
#
-
[base]
-
name=CentOS
-7-Base
-
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
-
baseurl=http:
//mirrors.163.com/centos/7/os/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#released updates
-
[updates]
-
name=CentOS
-7-Updates
-
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
-
baseurl=http:
//mirrors.163.com/centos/7/updates/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#additional packages that may be useful
-
[extras]
-
name=CentOS
-7-Extras
-
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
-
baseurl=http:
//mirrors.163.com/centos/7/extras/$basearch/
-
gpgcheck=
1
-
gpgkey=http:
//mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
-
-
#additional packages that extend functionality of existing packages
-
[centosplus]
-
name=CentOS
-7-Plus
-
baseurl=http:
//mirrors.163.com/centos/7/centosplus/$basearch/
-
gpgcheck=
1
-
enabled=
0
-
gpgkey=http:
//mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
9、执行下边两部
10:最后就是安装gcc了,安装完验证 ,成功了
第一次写,写的不好,见谅。希望此贴能对你有所帮助!!