Redhat通过yum安装配置gcc

说明:最近有个项目,客户要求服务器使用redhat,为了安全起见,自己要先演练演练看看有没有什么问题。公司网管装了虚拟机,拿到手装软件的时候发现make的时候报错,归因gcc工具没有。没有就安装咯。因为虚拟机不能直接上外网,申请开通上外网处理流程也麻烦,刚开始的想法是下载rpm安装。七搞八搞,废了九牛二虎之力,最终也没有搞好,原因包依赖太多,很多包下载源也找不到。

还是回到yum安装这条路上,不过RedHat 没有注册,使用yum install gcc的时候会出现This system is not registered with RHN;网上查了下可以通过更换源来进行相关更新:更改yum的源,即更换文件/etc/yum.repos.d/rhel-source.repo;网上其他文章说是rhel-debuginfo.repo,不过我的系统上只有rhel-source.repo,替换之后确实管用。

操作系统版本:
cat /etc/issue
Red Hat Enterprise Linux Server release 6.3 (Santiago)
Kernel \r on an \m

操作步骤:

步骤1:进入/etc/yum.repos.d/目录

cd /etc/yum.repos.d/

步骤2:终端输入以下命令,获取CentOS-Base.repo

wget http://mirrors.163.com/.help/CentOS6-base-163.repo

步骤3:切换到/etc/yum.repos.d目录,备份以前的repo文件,

cp rhel-source.repo rhel-source.repo.bak

步骤4:将CentOS-Base.repo改名为redhat的repo
mv CentOS-Base.repo rhel-source.repo


步骤5:因为网上已经不再6.7以前的版本提供了,因此将文件中的变量“$releaserver”替换为6.7,使用CentOS6.7文件

可以用vi工具编辑,也可以下载到pc上改完后再传上去,处理后文件如下

# 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-6.7 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6.7/os/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=i386&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$6.7 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.7/updates/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=i386&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.7 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.7/extras/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=i386&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.7/centosplus/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=i386&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.7 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.7/contrib/i386/
#mirrorlist=http://mirrorlist.centos.org/?release=6.7&arch=i386&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

好了,直接yum可以正常使用了,执行 yum -y install gcc即可完成安装

yum -y install gcc


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值